Skip to content

Commit

Permalink
Adding key strings to context for Req4 of issue ucoProject#423
Browse files Browse the repository at this point in the history
  • Loading branch information
kfairbanks committed Aug 5, 2022
1 parent ae338a9 commit eb32c44
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/uco_jsonld_context_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ def __process_ObjectPropertiesHelper(self, in_file=None):
#If rdf range is a blank node, skip
for triple in graph.triples((None,rdflib.RDF.type,rdflib.OWL.ObjectProperty)):
op_obj = ObjectPropertyInfo()
print(triple)
#print(triple)
#print(triple[0].split('/'))
s_triple=triple[0].split('/')
root=s_triple[-1]
ns_prefix=f"{s_triple[-3]}-{s_triple[-2]}"
print(ns_prefix, root)
#print(ns_prefix, root)
op_obj.ns_prefix=ns_prefix
op_obj.root_class_name=root

Expand Down Expand Up @@ -284,6 +284,7 @@ def print_minimal_datatype_properties(self)->str:
return(dtp_str_sect)

def add_minimal_datatype_props_to_cntxt(self) -> None:
"""Adds Datatype Properties to context string"""
dtp_str_sect=""
dt_list = list(self.datatype_properties_dict.keys())
dt_list.sort()
Expand All @@ -304,6 +305,7 @@ def add_minimal_datatype_props_to_cntxt(self) -> None:
self.context_str+=dtp_str_sect

def add_minimal_object_props_to_cntxt(self) -> None:
"""Adds Object Properties to context string"""
op_str_sect=""
op_list = list(self.object_properties_dict.keys())
op_list.sort()
Expand All @@ -315,6 +317,16 @@ def add_minimal_object_props_to_cntxt(self) -> None:

op_str_sect+=con_str
self.context_str+=op_str_sect

def add_key_strings_to_cntxt(self) -> None:
"""Adds id, type, and graph key strings to context string"""
ks_str=""
ks_str+="\t\"uco-core:id\":\"@id\",\n"
ks_str+="\t\"uco-core:type\":\"@type\",\n"
ks_str+="\t\"value\":\"@value\",\n"
ks_str+="\t\"graph\":\"@graph\",\n"

self.context_str+=ks_str



Expand All @@ -340,6 +352,7 @@ def main():
cb.add_prefixes_to_cntxt()
cb.add_minimal_object_props_to_cntxt()
cb.add_minimal_datatype_props_to_cntxt()
cb.add_key_strings_to_cntxt()
cb.close_context_str()
print(cb.context_str)

Expand Down

0 comments on commit eb32c44

Please sign in to comment.