Skip to content
Snippets Groups Projects
Commit 66fe62ee authored by Sabine Schröder's avatar Sabine Schröder
Browse files

upload real files and not the symbolic links

parent 3eb08240
No related branches found
No related tags found
No related merge requests found
Pipeline #53365 passed
/home/s.schroeder/controlled_vocabulary/TOAR-II-Ontology_2020-11-24.owl
\ No newline at end of file
This diff is collapsed.
/home/s.schroeder/controlled_vocabulary/TOARII_ontology.py
\ No newline at end of file
# coding: utf-8
"""
class TOAR_Ontology
===================
"""
import rdflib
from rdflib.namespace import RDF, RDFS
g = rdflib.Graph()
result = g.parse("TOAR-II-Ontology_2020-11-24.owl",format='json-ld')
#print("graph has %s statements." % len(g))
class TOAR_Ontology:
"""
some information
"""
def get_class(title):
"""
find the right class for the given title
"""
for s, p, o in g.triples( (None, RDF.type, rdflib.URIRef("http://www.w3.org/2002/07/owl#Class") ) ):
value = g.value(subject=s,predicate=RDFS.label)
if value and value.strip() == title.strip():
ont_class = s
return ont_class
def show_entries(ont_class):
"""
show information on given ontology class
"""
print(f"show information on '{ont_class}'")
for s, p, o in g.triples( (None, RDF.type, ont_class ) ):
print("%s is %s"%(s, g.value(subject=s,predicate=RDFS.label)))
def check_entry(entry, ont_class):
"""
check whether entry is a valid value of the ontology
"""
found=False
for s, p, o in g.triples( (None, RDF.type, ont_class ) ):
if g.value(subject=s,predicate=RDFS.label).strip() == entry:
found=True
return found
# #check_entry would have been nicer, if something like this worked:
# subj2 = rdflib.URIRef("http://www.fz-juelich.de/ontologies/2020/ToarOntotology#OWLNamedIndividual_000141")
# pred2 = RDFS.label
# obj2 = rdflib.Literal("Croplands")
# passed = ((subj2, pred2, obj2) in g)
# if not passed:
# print("sub: ", subj2, "\npred: ", pred2, "\nobj: ", obj2, "\nnot found in ontology!\n")
# else:
# print("sub: ", subj2, "\npred: ", pred2, "\nobj: ", obj2, "\nfound in ontology!\n")
# # getting the literals directly here:
# subj2 = rdflib.URIRef("http://www.fz-juelich.de/ontologies/2020/ToarOntotology#OWLNamedIndividual_000141")
# generator = g.objects(subj2, RDFS.label)
# for lit in generator:
# print(lit.value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment