Commit f2622a8f authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

find the system list

parent c78fb6f5
...@@ -27,7 +27,7 @@ MAIN_CHOICES = ( ("",""), ("M1", "M1 : system/function shall [not] set [<quant ...@@ -27,7 +27,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 = (("SYSTEM", "SYSTEM"), ("SYSTEM2", "SYSTEM2")) #SYSTEM_CHOICES = (("SYSTEM", "SYSTEM"), ("SYSTEM2", "SYSTEM2"))
SYSTEM_CHOICES = get_keyword("SAO:System") SYSTEM_CHOICES = find_extra_keywords("SAO:System")
FUNCTION_CHOICES = (("FUNCTION", "FUNCTION"), ("FUNCTION2", "FUNCTION2")) FUNCTION_CHOICES = (("FUNCTION", "FUNCTION"), ("FUNCTION2", "FUNCTION2"))
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"),
......
IS_SAO_SYSTEM = "SAO:System" IS_SAO_SYSTEM = "SAO:System"
list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"] list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"]
system_list = []
'''Return the Systems from the Ontologies''' '''Return the Systems from the Ontologies'''
def get_keyword(keyword): def get_keyword(keyword):
system_list = []
with open("../../Ontologies/Mokos_18_1_7_47.ttl") as f: with open("../../Ontologies/Mokos_18_1_7_47.ttl") as f:
for dso in list_of_DSO : for dso in list_of_DSO :
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
...@@ -15,14 +16,35 @@ def get_keyword(keyword): ...@@ -15,14 +16,35 @@ def get_keyword(keyword):
key = spliter_2[0].strip() key = spliter_2[0].strip()
flag_1 = 1 flag_1 = 1
if flag_1 == 1: if flag_1 == 1:
if keyword in line: if ':' in keyword:
if keyword in line and "subClassOf" in line:
flag_2 = 1
elif not ':' in keyword:
keyword = ':'+keyword
if keyword in line and "subClassOf" in line:
flag_2 = 1 flag_2 = 1
if flag_1 == 1 and flag_2 == 1: if flag_1 == 1 and flag_2 == 1:
if (line.strip()).endswith('.'): if (line.strip()).endswith('.'):
if not key in system_list:
system_list.append(key) system_list.append(key)
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
if (line.strip()).endswith('.'): if (line.strip()).endswith('.') and not ((line.strip()).startswith('-') or (line.strip()).startswith('rdfs:comment')) :
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
return tuple((str(n), str(n)) for n in system_list) return system_list
def find_extra_keywords(keyword):
first_search = get_keyword(keyword)
second_search = first_search.copy()
for i in first_search:
k = get_keyword(i)
for kl in k:
if not kl in second_search:
second_search.append(kl)
third_search = second_search.copy()
for i in second_search:
k = get_keyword(i)
for kl in k:
if not kl in third_search:
third_search.append(kl)
return tuple((str(n), str(n)) for n in third_search)
\ No newline at end of file
IS_SAO_SYSTEM = "SAO:System" IS_SAO_SYSTEM = ":Interface"
list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"] list_of_DSO = ["DSO", "DSO-AOCS", "DSO-AOCS-instances"]
system_list = []
'''Return the Systems from the Ontologies''' '''Return the Systems from the Ontologies'''
def get_keyword(keyword): def get_keyword(keyword):
system_list = []
with open("../Ontologies/Mokos_18_1_7_47.ttl") as f: with open("../Ontologies/Mokos_18_1_7_47.ttl") as f:
for dso in list_of_DSO : for dso in list_of_DSO :
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
...@@ -15,20 +16,44 @@ def get_keyword(keyword): ...@@ -15,20 +16,44 @@ def get_keyword(keyword):
key = spliter_2[0].strip() key = spliter_2[0].strip()
flag_1 = 1 flag_1 = 1
if flag_1 == 1: if flag_1 == 1:
if keyword in line: if ':' in keyword:
if keyword in line and "subClassOf" in line:
flag_2 = 1
elif not ':' in keyword:
keyword = ':'+keyword
if keyword in line and "subClassOf" in line:
flag_2 = 1 flag_2 = 1
if flag_1 == 1 and flag_2 == 1: if flag_1 == 1 and flag_2 == 1:
if (line.strip()).endswith('.'): if (line.strip()).endswith('.'):
if not key in system_list: if not key in system_list:
system_list.append(key) system_list.append(key)
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
if (line.strip()).endswith('.'): if (line.strip()).endswith('.') and not ((line.strip()).startswith('-') or (line.strip()).startswith('rdfs:comment')) :
flag_1, flag_2 = 0, 0 flag_1, flag_2 = 0, 0
return system_list #tuple((str(n), str(n)) for n in system_list) return system_list #tuple((str(n), str(n)) for n in system_list)
def find_extra_keywords(keyword):
first_search = get_keyword(keyword)
second_search = first_search.copy()
for i in first_search:
k = get_keyword(i)
print(i)
print(k)
for kl in k:
if not kl in second_search:
second_search.append(kl)
third_search = second_search.copy()
for i in second_search:
k = get_keyword(i)
print(i)
print(k)
for kl in k:
if not kl in third_search:
third_search.append(kl)
return tuple((str(n), str(n)) for n in third_search)
m = get_keyword(IS_SAO_SYSTEM) print(find_extra_keywords(IS_SAO_SYSTEM))
for i in m: print(get_keyword(IS_SAO_SYSTEM))
get_keyword(i) \ No newline at end of file
print(system_list)
\ No newline at end of file
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