A Python package for ontology verbalization
Project description
OWL Ontology Verbalizer
Installation
pip install ontology-verbalizer
Usage
Configure URIs to ignore or rename
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'
}
Configure LLM of choice
from verbalizer.nlp import ChatGptModelParaphrase
model = ChatGptModelParaphrase(api_key='sk-xyz', model='gpt-4o', temperature=0.7)
Perform Verbalization
from verbalizer.process import Processor
from verbalizer.vocabulary import Vocabulary
from verbalizer import Verbalizer
ontology = Processor.from_file('pizza.ttl')
# create vocabulary and verbalizer
vocab = Vocabulary(ontology, ignore=ignore, rephrased=rephrased)
verbalizer = Verbalizer(vocab)
# start verbalization process
results = Processor.verbalize_with(verbalizer, namespace="pizza", output_dir="./output")
Examples
Expand to see examples
| 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. |
Citation
@inproceedings{zaitoun2024generating,
title={Generating Ontology-Learning Training-Data through Verbalization},
author={Zaitoun, Antonio and Sagi, Tomer and Peleg, Mor},
booktitle={Proceedings of the AAAI Symposium Series},
volume={4},
number={1},
pages={233--241},
year={2024}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ontology_verbalizer-1.1.2.tar.gz.
File metadata
- Download URL: ontology_verbalizer-1.1.2.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0577046d0186ccda096d47b92e67ab6044c4d78dd2d4d68cf65a0aa8c96b774
|
|
| MD5 |
1686ff65a25325e434ced0bd1837d573
|
|
| BLAKE2b-256 |
d0c15c2adb9023602f73984ac3b1ce1b4ea220ccb92660ae4bd6abab98f51ce6
|
File details
Details for the file ontology_verbalizer-1.1.2-py3-none-any.whl.
File metadata
- Download URL: ontology_verbalizer-1.1.2-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.12.8 Linux/6.8.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0d4176ca68d5d01edc3d96ee294aa209c3ca9191d86c1e1f7505a7a856509c1
|
|
| MD5 |
06f7d305f21b6a4955eba9b3bb22cbc5
|
|
| BLAKE2b-256 |
53b99d45dac5d5efa86b002b18f14c2470c848fd12bcfa4c5d8b4654d3b03ab2
|