pip install ontology-verbalizer
ignore = {
'http://www.w3.org/2002/07/owl#onDatatype',
'http://www.w3.org/2000/01/rdf-schema#seeAlso',
'http://www.w3.org/2000/01/rdf-schema#label',
'http://www.w3.org/2000/01/rdf-schema#comment',
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
'http://www.w3.org/2000/01/rdf-schema#isDefinedBy',
}
rephrased = {
'http://www.w3.org/2002/07/owl#equivalentClass': 'is same as',
'http://www.w3.org/2000/01/rdf-schema#subClassOf': 'is a type of',
'http://www.w3.org/2002/07/owl#intersectionOf': 'all of',
'http://www.w3.org/2002/07/owl#unionOf': 'any of',
'http://www.w3.org/2002/07/owl#disjointWith': 'is different from',
'http://www.w3.org/2002/07/owl#withRestrictions': 'must be'
}
from verbalizer.nlp import ChatGptModelParaphrase
model = ChatGptModelParaphrase(api_key='sk-xyz', model='gpt-4o', temperature=0.7)
from verbalizer.process import Processor
ontology = 'pizza.ttl'
name = 'pizza'
processor = Processor(llm=model, vocab_ignore=ignore, vocab_rephrased=rephrased, min_statements=1)
processor.process(name, ontology, output_dir='/path/to/my/output')
OWL Fragment | Pseudo Text | LLM Text |
---|---|---|
@prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
deep pan base is a type of a pizza base. deep pan base is different from a thin and crispy base. |
A deep pan base is a type of pizza base that differs from a thin and crispy base. |
@prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
capricciosa is a type of a named pizza. capricciosa is a type of at least has topping some a caper topping. capricciosa is a type of at least has topping some a ham topping. capricciosa is a type of at least has topping some a mozzarella topping. capricciosa is a type of at least has topping some a peperonata topping. capricciosa is a type of at least has topping some a tomato topping. capricciosa is a type of at least has topping some an anchovies topping. capricciosa is a type of at least has topping some an olive topping. capricciosa is a type of only has topping any of (a tomato topping, and a ham topping, and a mozzarella topping, and an anchovies topping, and an olive topping, and a peperonata topping, and a caper topping). capricciosa is different from (a la reine, and a frutti di mare, and a fiorentina, and a margherita, and a sloppy giuseppe, and a veneziana, and an american hot, and an unclosed pizza, and a mushroom, and a pollo ad astra, and a caprina, and a cajun, and a giardiniera, and an american, and a prince carlo, and a siciliana, and a parmense, and a rosa, and a soho, and a quattro formaggi, and a four seasons, and a napoletana). |
Capricciosa is a specific type of pizza that includes various toppings. It features caper, ham, mozzarella, peperonata, tomato, anchovies, and olive toppings. This pizza exclusively contains these toppings and does not have any other toppings. Capricciosa is distinct from other pizzas such as la reine, frutti di mare, fiorentina, margherita, sloppy giuseppe, veneziana, american hot, unclosed pizza, mushroom, pollo ad astra, caprina, cajun, giardiniera, american, prince carlo, siciliana, parmense, rosa, soho, quattro formaggi, four seasons, and napoletana. |
@prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
chicken topping is a type of a meat topping. chicken topping is a type of at least has spiciness some a mild. chicken topping is different from (a peperoni sausage topping, and a hot spiced beef topping, and a ham topping). |
Chicken topping is a type of meat topping that has at least some mild spiciness. It is different from pepperoni sausage topping, hot spiced beef topping, and ham topping. |