tools4RDF is a Python toolkit for working with RDF data, SPARQL queries, and semantic networks.
It allows one or more ontologies to be parsed and represented as Python classes, making it easier to navigate and explore their structure through features like autocompletion in interactive environments such as Jupyter notebooks.
The aim is to make querying knowledge graphs with SPARQL more accessible to users without deep expertise in semantic web technologies.
- Load and serialize RDF graphs (Turtle, RDF/XML, N-Triples, etc.)
- Compose and run SPARQL queries programmatically
- Auto-discover ontology terms via dot-access
- Query graphs and return results as
pandas
DataFrames - Perform graph merging and basic path reasoning
pip install tools4rdf
Or:
conda install -c conda-forge tools4rdf
from tools4rdf import OntologyNetwork
onto = OntologyNetwork('http://xmlns.com/foaf/0.1/')
df = onto.query(
'https://dbpedia.org/sparql',
onto.terms.foaf.Person,
onto.terms.foaf.familyName,
limit=10,
)
More examples available in the docs.
MIT License
Issues and pull requests are welcome! Feel free to suggest new utilities or improvements.
This work is supported by the NFDI-Matwerk consortia.
Funded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) under the National Research Data Infrastructure – NFDI 38/1 – project number 460247524