Skip to content
Snippets Groups Projects
Commit 3c55b0e9 authored by Cornelia Michlits's avatar Cornelia Michlits
Browse files

104 ontology - adjust rdflib version

parent a3fa8eca
No related branches found
No related tags found
4 merge requests!81New stable release,!43Merge dev to master,!33Draft: merge dev to master,!32Add units-service to dev
......@@ -15,7 +15,9 @@ g.parse('onto/om-2.ttl', format='turtle')
om = rdflib.Namespace('http://www.ontology-of-units-of-measure.org/resource/om-2/')
rdf_schema = rdflib.Namespace('http://www.w3.org/2000/01/rdf-schema#')
def list_units(string):
r={}
def list_units(string,offset=0):
if bool(re.match('^[a-zA-Z0-9]+$',string)):
l_query = """
SELECT ?symbol ?name ?comment
......@@ -24,9 +26,26 @@ def list_units(string):
?unit <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?unit <http://www.w3.org/2000/01/rdf-schema#comment> ?comment .
FILTER regex(str(?unit),\""""+string+"""\","i")
} LIMIT 10 """
} LIMIT 10 OFFSET """+str(offset)
qres = g.query(l_query)
units = list()
for row in qres:
units.append({"symbol": str(row.symbol), "name": str(row.name), "comment": str(row.comment)})
return units
else:
return None
def get_uri(name):
if bool(re.match('^[a-zA-Z0-9]+$',name)):
uri_query = """
SELECT ?uri
WHERE {
?uri <http://www.w3.org/2000/01/rdf-schema#label> ?o .
FILTER (str(?o)=\""""+name+"""\")
} LIMIT 1
"""
qres = g.query(uri_query)
for row in qres:
print(f"{row.symbol} | {row.name} | {row.comment}")
return {"URI": row.uri}
else:
return 'not alphanumeric'
\ No newline at end of file
return None
\ No newline at end of file
......@@ -3,4 +3,4 @@ flasgger==0.9.5
py-eureka-client==0.9.1
docker==5.0.0
gevent==21.8.0
rdflib==6.0.1
rdflib==6.0.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment