Commit faeeecfc authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

add an extra method for finding instances

parent c9fd6f23
...@@ -29,7 +29,7 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1 : system/function shall [not] set [<quant ...@@ -29,7 +29,7 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1 : system/function shall [not] set [<quant
) )
#to be updated with domains from DSO #to be updated with domains from DSO
SYSTEM_CHOICES = get_instances("SAO#System") SYSTEM_CHOICES = get_instances("SAO#System") #+get_i_instances("SAO#System")
FUNCTION_CHOICES = get_instances("SAO#Function") FUNCTION_CHOICES = get_instances("SAO#Function")
SHALL_CHOICES = ( ("shall", "SHALL"), ("shall not", "SHALL NOT")) SHALL_CHOICES = ( ("shall", "SHALL"), ("shall not", "SHALL NOT"))
QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"), QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"),
...@@ -38,10 +38,12 @@ QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"), ...@@ -38,10 +38,12 @@ QUANTIFIER_CHOICES = ( ("none","NONE"), ("all", "ALL"), ("only", "ONLY"),
) )
NUMBER_UNITS_CHOICES = (("",""), ("meters","METERS"), ("kilometers","KILOMETERS"), ("volt","VOLT")) NUMBER_UNITS_CHOICES = (("",""), ("meters","METERS"), ("kilometers","KILOMETERS"), ("volt","VOLT"))
ITEM_CHOICES = get_instances("SAO#Item") ITEM_CHOICES = get_instances("SAO#Item")
STATE_VALUE_CHOICES =get_instances("SAO#StateValue") STATE_VALUE_CHOICES =get_i_instances("SAO#StateValue")
#print(STATE_VALUE_CHOICES)
STATE_CHOICES = get_instances("SAO#State") STATE_CHOICES = get_instances("SAO#State")
#state set not working #nothing return get_instances
STATE_SET_CHOICES = get_instances("SAO#StateSet") STATE_SET_CHOICES = get_i_instances("SAO#StateSet")
#print(STATE_SET_CHOICES)
FLOW_CHOICES = get_instances("SAO#Flow") FLOW_CHOICES = get_instances("SAO#Flow")
INTERFACE_CHOICES = get_instances("SAO#Interface") INTERFACE_CHOICES = get_instances("SAO#Interface")
CONNECTION_CHOICES = get_instances("SAO#Connection") CONNECTION_CHOICES = get_instances("SAO#Connection")
......
...@@ -9,7 +9,7 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace ...@@ -9,7 +9,7 @@ from rdflib import ConjunctiveGraph, URIRef, RDFS, RDF, Namespace
Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl" Ontology_file = "../../Ontologies/Mokos_18_1_7_47.ttl"
subClass_instances = "../../Ontologies/instances_subclass.txt" subClass_instances = "../../Ontologies/instances_subclass.txt"
list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#"] list_of_DSO = ["http://delab.csd.auth.gr/ontologies/2018/SAO#","http://delab.csd.auth.gr/ontologies/2018/DSO#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS#", "http://delab.csd.auth.gr/ontologies/2018/DSO-AOCS-instances#"]
list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"] list_of_RMO = ["RMO", "RMO-instances", "DSO-AOCS-instances", "<http://delab.csd.auth.gr/ontologies/2018/RDO-instances"]
g = Graph() g = Graph()
...@@ -36,6 +36,16 @@ def findsubclass(): ...@@ -36,6 +36,16 @@ def findsubclass():
subClass = subj + "$"+ obj + "\n" subClass = subj + "$"+ obj + "\n"
file2.write(subClass) file2.write(subClass)
def get_i_instances(keyword):
out_list = []
per = URIRef("http://delab.csd.auth.gr/ontologies/2018/"+keyword)
for s, p, o in g.triples((None, RDF.type, per)):
split = s.split("#")
out_list.append(split[len(split) - 1])
return tuple((str(n), str(n)) for n in (out_list))
'''Get Instaces - return tuple''' '''Get Instaces - return tuple'''
def get_instances(keyword): def get_instances(keyword):
in_list = [] in_list = []
...@@ -52,7 +62,7 @@ def get_instances(keyword): ...@@ -52,7 +62,7 @@ def get_instances(keyword):
for s, p, o in g.triples((None, RDF.type, p)): for s, p, o in g.triples((None, RDF.type, p)):
split = s.split("#") split = s.split("#")
out_list.append(split[len(split) - 1]) out_list.append(split[len(split) - 1])
return tuple((str(n), str(n)) for n in (in_list + out_list)) return tuple((str(n), str(n)) for n in (out_list))
'''Get Instaces - return list''' '''Get Instaces - return list'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment