diff --git a/structure/cts/amr_ctr/transduction/atomic_extraction.py b/structure/cts/amr_ctr/transduction/atomic_extraction.py index 69b2bf76deb6747e2555782d50d07e1de9074bc8..91d3d02eb1938d9ef3d2657e28e87ceba0c0bd32 100644 --- a/structure/cts/amr_ctr/transduction/atomic_extraction.py +++ b/structure/cts/amr_ctr/transduction/atomic_extraction.py @@ -490,19 +490,19 @@ if __name__ == '__main__': print('\n' + ' -- test: update a test query') test_query= f"""[...] CONSTRUCT {{ - {atom_class_net.construct('?node1', - structure='?structureRef', - class_name='?leaf1ConceptLabel')} + {atom_class_net.construct(base_node='{{node1.id}}', + structure='{{structure.sentence_ref}}', + class_name='{{node1.concept_label}}')} {atom_class_net.propagate_relations()} }} WHERE {{ - {{node.identify()}} - ?concept rdfs:subClassOf amr:AMR_Term_Concept. - ?concept amr:label ?conceptName. - ?variable amr:label ?varLabel. + {{node1.identify(type='AMR_Term_Concept')}} + {{node1.concept}} rdfs:subClassOf amr:AMR_Term_Concept. + {{node1.concept}} amr:label ?conceptName. + {{node1.variable}} amr:label ?varLabel. {{structure.identify()}} diff --git a/structure/cts/amr_ctr/transduction/query_builder/binding.py b/structure/cts/amr_ctr/transduction/query_builder/binding.py deleted file mode 100644 index 8397351353bf54c2e33e5b7477cb454e37228633..0000000000000000000000000000000000000000 --- a/structure/cts/amr_ctr/transduction/query_builder/binding.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/python3.10 -# -*-coding:Utf-8 -* - -#============================================================================== -# TENET: Binding Query Builder -#------------------------------------------------------------------------------ -# Module offering different functions to build SPARQL queries of transduction -# rules, for binding query part. -#============================================================================== - -#============================================================================== -# Importing required modules -#============================================================================== - -# -- - - -#============================================================================== -# Data Repository -#============================================================================== - -# -- Default References - -DEFAULT_NET_ID = '?newNet' -DEFAULT_NET_TYPE = 'Net' -DEFAULT_SENTENCE_REF = '?sentenceRef' -DEFAULT_BASE_LEAF = '?baseLeaf' -DEFAULT_CLASS_NAME = '?className' - - -# -- Reference Table - -DATA_PROPERTY_TABLE = { - 'sentence_ref': 'hasStructure', - 'class_name': 'hasClassName', - 'mother_class_net': 'hasMotherClassNet', - 'individual_label': 'hasIndividualLabel' - } - - -#============================================================================== -# Useful Functions -#============================================================================== - -# -- - - -#============================================================================== -# Main Functions -#============================================================================== - -def new_variable(id): - return f"*** new_variable(id) ***" - - -#============================================================================== -# Development Test -#============================================================================== - -if __name__ == '__main__': - - print('\n' + ' *** Development Test ***') - - print('\n' + ' -- test: todo') - - print('\n' + ' *** - ***') \ No newline at end of file diff --git a/structure/cts/amr_ctr/transduction/query_builder/clause.py b/structure/cts/amr_ctr/transduction/query_builder/clause.py deleted file mode 100644 index 9281876ba842a6a0774988e1446a9ab3176b1e17..0000000000000000000000000000000000000000 --- a/structure/cts/amr_ctr/transduction/query_builder/clause.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/python3.10 -# -*-coding:Utf-8 -* - -#============================================================================== -# TENET: Clause Query Builder -#------------------------------------------------------------------------------ -# Module offering different functions to build SPARQL queries of transduction -# rules, for clause query part. -#============================================================================== - -#============================================================================== -# Importing required modules -#============================================================================== - -# -- - - -#============================================================================== -# Data Repository -#============================================================================== - -# -- Default References - -DEFAULT_NET_ID = '?newNet' -DEFAULT_NET_TYPE = 'Net' -DEFAULT_SENTENCE_REF = '?sentenceRef' -DEFAULT_BASE_LEAF = '?baseLeaf' -DEFAULT_CLASS_NAME = '?className' - - -# -- Reference Table - -DATA_PROPERTY_TABLE = { - 'sentence_ref': 'hasStructure', - 'class_name': 'hasClassName', - 'mother_class_net': 'hasMotherClassNet', - 'individual_label': 'hasIndividualLabel' - } - - -#============================================================================== -# Useful Functions -#============================================================================== - -# -- - - -#============================================================================== -# Main Functions -#============================================================================== - -def identify_node(concept, variable): - return f"*** identify_node(concept, variable) ***" - - -def identify_structure(): - return f"*** identify_structure ***" - - -def identify_relations_for_propagation(net_id): - return f"*** identify_relations_for_propagation()***" - - -#============================================================================== -# Development Test -#============================================================================== - -if __name__ == '__main__': - - print('\n' + ' *** Development Test ***') - - print('\n' + ' -- test: todo') - - print('\n' + ' *** - ***') \ No newline at end of file diff --git a/structure/cts/amr_ctr/transduction/query_builder/construct.py b/structure/cts/amr_ctr/transduction/query_builder/construct.py deleted file mode 100644 index b110da1f20ca98ae28a586bbb63cb44f3bf461ef..0000000000000000000000000000000000000000 --- a/structure/cts/amr_ctr/transduction/query_builder/construct.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/python3.10 -# -*-coding:Utf-8 -* - -#============================================================================== -# TENET: Construct Query Builder -#------------------------------------------------------------------------------ -# Module offering different functions to build SPARQL queries of transduction -# rules, for construct query part. -#============================================================================== - -#============================================================================== -# Importing required modules -#============================================================================== - -# -- - - -#============================================================================== -# Data Repository -#============================================================================== - -# -- Default References - -DEFAULT_NET_ID = '?newNet' -DEFAULT_NET_TYPE = 'Net' -DEFAULT_SENTENCE_REF = '?sentenceRef' -DEFAULT_BASE_LEAF = '?baseLeaf' -DEFAULT_CLASS_NAME = '?className' - - -# -- Reference Table - -DATA_PROPERTY_TABLE = { - 'sentence_ref': 'hasStructure', - 'class_name': 'hasClassName', - 'mother_class_net': 'hasMotherClassNet', - 'individual_label': 'hasIndividualLabel' - } - - -#============================================================================== -# Useful Functions -#============================================================================== - -def get_net_type(net_type): - if not net_type.startswith('net:'): - net_type = f'net:{net_type}' - return net_type - - -def get_data_property(data_ref): - property_name = DATA_PROPERTY_TABLE[f'{data_ref}'] - return f'net:{property_name}' - - -def get_net_data(net_id, **net_data): - data_str = "" - for data_ref, data_val in net_data.items(): - data_property = get_data_property(data_ref) - data_str += f"{net_id} {data_property} {data_val}.\n " - return data_str - - -#============================================================================== -# Main Functions -#============================================================================== - -def new_net(net_id=DEFAULT_NET_ID, - net_type=DEFAULT_NET_TYPE, - base_leaf=DEFAULT_BASE_LEAF, - **net_data ): - - return f""" - # -- New Class Net - {net_id} a {get_net_type(net_type)}. - {net_id} net:coverBaseNode {base_leaf}. - {get_net_data(net_id, **net_data)}""" - - -def relation_propagation(net_id=DEFAULT_NET_ID): - - return f""" - # -- Propagation of relations (from nodes to nets) - ?inRelationRole a net:Relation. - ?inNet ?inRelationRole {net_id}. - ?outRelationRole a net:Relation. - {net_id} ?outRelationRole ?outNet.""" - - -#============================================================================== -# Development Test -#============================================================================== - -if __name__ == '__main__': - - print('\n' + ' *** Development Test ***') - - print('\n' + ' -- test: get_net_data()') - test_str = get_net_data('?newNet', class_name='?conceptName') - print(test_str) - - - print('\n' + ' -- test: new_net') - test_str = new_net(class_name='?conceptName') - print(test_str) - test_str = new_net(net_type='Atom_Class_Net', class_name='?conceptName') - print(test_str) - - print('\n' + ' -- test: update a test query') - test_query= f"""[...] - CONSTRUCT {{ - {new_net(net_type='Atom_Class_Net', - sentence_ref='?sentenceRef', - class_name='?conceptName')} - - {relation_propagation()} - - }} - WHERE {{ - clause_1 - clause_2 - [...] - binding - }} - """ - print(test_query) - - print('\n' + ' *** - ***') \ No newline at end of file diff --git a/tenet.log b/tenet.log index 64071c74e5bad82985916d07de06fea439a50113..e44734ab248c43ba49711b5a3d789b58b214d084 100644 --- a/tenet.log +++ b/tenet.log @@ -66,7 +66,7 @@ - DEBUG - --- Export work graph as turtle - DEBUG - ----- Work graph file: ./output/SolarSystemDev1-20221214/SolarSystemDev1-1/SolarSystemDev1.ttl - DEBUG - --- Ending Structure Preparation -- DEBUG - ----- Total Execution Time = 0:00:00.116396 +- DEBUG - ----- Total Execution Time = 0:00:00.201392 - INFO - -- Loading Extraction Scheme (amr_scheme_1) - DEBUG - ----- Step number: 3 - INFO - -- Loading Extraction Rules (amr_ctr/*) @@ -216,8 +216,8 @@ - INFO - *** Execution Time *** ----- Function: apply (lib.tenet_extraction) ------ Total Time: 0:00:06.149423 ------ Process Time: 0:00:06.139959 +----- Total Time: 0:00:08.164996 +----- Process Time: 0:00:08.033522 *** - *** - INFO - === Final Ontology Generation === - INFO - -- Making complete factoid graph by merging sentence factoid graphs