From 4abf602d4b682754ec94caeffce931a4468ec696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?= <aurelien.lamercerie@tetras-libre.fr> Date: Fri, 16 Dec 2022 00:15:30 +0100 Subject: [PATCH] Update Query Builder with new classes --- .../amr_ctr/transduction/atomic_extraction.py | 7 +- .../transduction/query_builder/builders.py | 18 +- .../query_builder/element/atom_class_net.py | 152 +++++++++++ .../element/atom_property_net.py | 171 +++++++++++++ .../query_builder/element/individual_net.py | 173 +++++++++++++ .../transduction/query_builder/element/net.py | 160 ++++++------ .../query_builder/element/old_net.py | 235 ++++++++++++++++++ .../query_builder/element/phenomena_net.py | 171 +++++++++++++ tenet.log | 194 +++++++-------- 9 files changed, 1095 insertions(+), 186 deletions(-) create mode 100644 structure/cts/amr_ctr/transduction/query_builder/element/atom_class_net.py create mode 100644 structure/cts/amr_ctr/transduction/query_builder/element/atom_property_net.py create mode 100644 structure/cts/amr_ctr/transduction/query_builder/element/individual_net.py create mode 100644 structure/cts/amr_ctr/transduction/query_builder/element/old_net.py create mode 100644 structure/cts/amr_ctr/transduction/query_builder/element/phenomena_net.py diff --git a/structure/cts/amr_ctr/transduction/atomic_extraction.py b/structure/cts/amr_ctr/transduction/atomic_extraction.py index f3a69eb8..df62dca6 100644 --- a/structure/cts/amr_ctr/transduction/atomic_extraction.py +++ b/structure/cts/amr_ctr/transduction/atomic_extraction.py @@ -32,10 +32,7 @@ rule_set['create-atom-class-net'] = { 'comment': "Create Atom Class Net from AMR Term Concept", 'construction': f""" {atom_class_net.construct(base_node='?leaf1', - structure=structure.sentence_ref, class_name='?conceptName')} - - {atom_class_net.propagate_relations()} """, 'clause': f""" # -- Identify Class covering a single leaf @@ -45,10 +42,8 @@ rule_set['create-atom-class-net'] = { ?variable amr:label ?varLabel. ?leaf1Concept rdfs:subClassOf amr:AMR_Term_Concept. ?leaf1Concept amr:label ?conceptName. - - {structure.identify()} - {atom_class_net.identify_relations_for_propagation('?leaf1')} + {atom_class_net.complete_clauses_for_construction('?leaf1')} """, 'binding': f""" {atom_class_net.bind_uri('?conceptName', '?varLabel')} diff --git a/structure/cts/amr_ctr/transduction/query_builder/builders.py b/structure/cts/amr_ctr/transduction/query_builder/builders.py index 98afbf32..39fb12a7 100644 --- a/structure/cts/amr_ctr/transduction/query_builder/builders.py +++ b/structure/cts/amr_ctr/transduction/query_builder/builders.py @@ -12,8 +12,10 @@ # Importing required modules #============================================================================== -from .element.net import * -from .element.structure import * +from .element.old_net import OldNet +from .element.net import Net +from .element.atom_class_net import AtomClassNet +from .element.structure import Structure #============================================================================== @@ -28,18 +30,18 @@ structure = Structure() #============================================================================== # -- Atom Class Net -atom_class_net = Net('atomClass') -atom_class_net_1 = Net('atomClass', 1) -atom_class_net_2 = Net('atomClass', 2) +atom_class_net = AtomClassNet() +atom_class_net_1 = AtomClassNet(1) +atom_class_net_2 = AtomClassNet(2) # -- Individual Net -individual_net = Net('individual') +individual_net = OldNet('individual') # -- Atom Property Net -atom_property_net = Net('atomProperty') +atom_property_net = OldNet('atomProperty') # -- Phenomena Net -phenomena_net = Net('phenomena') +phenomena_net = OldNet('phenomena') #============================================================================== diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/atom_class_net.py b/structure/cts/amr_ctr/transduction/query_builder/element/atom_class_net.py new file mode 100644 index 00000000..5eee5f23 --- /dev/null +++ b/structure/cts/amr_ctr/transduction/query_builder/element/atom_class_net.py @@ -0,0 +1,152 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Net Query Builder +#------------------------------------------------------------------------------ +# Class to generate SPARQL query parts related to semantic nets +#============================================================================== + +#============================================================================== +# Importing required modules +#============================================================================== + +from .net import Net + + +#============================================================================== +# Data Repository +#============================================================================== + +# -- Reference Table + +# NET_TYPE_TABLE = { # *** [type_name: type_id] *** +# 'default': 'Net', +# 'atomClass': 'Atom_Class_Net', +# 'individual': 'Individual_Net', +# 'atomProperty': 'Atom_Property_Net', +# 'phenomena': 'Phenomena_Net' +# } + +# PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** +# 'structure': 'hasStructure', + +# 'class_name': 'hasClassName', + +# 'mother_class_net': 'hasMotherClassNet', +# 'individual_label': 'hasIndividualLabel', + +# 'core_role': 'isCoreRoleLinked', +# 'target_argument_node': 'targetArgumentNode', +# 'property_type': 'hasPropertyType', +# 'property_name': 'hasPropertyName', +# 'property_name01': 'hasPropertyName01', +# 'property_name10': 'hasPropertyName10', +# 'property_name12': 'hasPropertyName12', + +# 'phenomena_type': 'hasPhenomenaType', +# 'phenomena_ref': 'hasPhenomenaRef' +# } + +# -- Default Value(s) + +DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' + + +# -- Useful Constant(s) + +TRIPLE_ENDING_STR = '\n ' + + + +#============================================================================== +# Net Class +#============================================================================== + +class AtomClassNet(Net): + """ Class to generate SPARQL query parts related to semantic nets. + """ + + predicate_table = Net.predicate_table + predicate_table.update({ + 'class_name': 'hasClassName' + }) + + #-------------------------------------------------------------------------- + # Constructor(s) + #-------------------------------------------------------------------------- + + def __init__(self, num=''): + + super().__init__(num) + + # -- Net Signature + self.type_name = 'atomClass' + self.type_id = 'Atom_Class_Net' + self.id = f'?{self.type_name}Net{num}' + self.type_uri = f'net:{self.type_id}' + + # -- Net Attributes + self.class_name = f'{self.id}ClassName' + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Construct' parts + #-------------------------------------------------------------------------- + + def construct(self, **net_attribute): + query_code = super().construct(**net_attribute) + return query_code + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Binding' parts + #-------------------------------------------------------------------------- + + def bind_uri(self, net_name='nameless', node_reference='00'): + return super().bind_uri(net_name, node_reference) + + + +#============================================================================== +# Development Test +#============================================================================== + +if __name__ == '__main__': + + print('\n' + ' *** Development Test ***') + + print('\n' + ' -- test: Atom Class Net') + atom_class_net = AtomClassNet() + print(atom_class_net) + + + print('\n' + ' -- test: construct') + construct_ctr = atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel') + print(construct_ctr) + + print('\n' + ' -- test: update a test query') + test_query= f"""[...] + CONSTRUCT {{ + {atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel')} + + {atom_class_net.propagate_relations()} + + }} + WHERE {{ + clause_1 + clause_2 + + {atom_class_net.identify_relations_for_propagation('?node1')} + + {atom_class_net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} + }} + """ + print(test_query) + + print('\n' + ' *** - ***') \ No newline at end of file diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/atom_property_net.py b/structure/cts/amr_ctr/transduction/query_builder/element/atom_property_net.py new file mode 100644 index 00000000..c8cb2bd7 --- /dev/null +++ b/structure/cts/amr_ctr/transduction/query_builder/element/atom_property_net.py @@ -0,0 +1,171 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Net Query Builder +#------------------------------------------------------------------------------ +# Class to generate SPARQL query parts related to semantic nets +#============================================================================== + +#============================================================================== +# Importing required modules +#============================================================================== + +from net import Net + + +#============================================================================== +# Data Repository +#============================================================================== + +# -- Reference Table + +# NET_TYPE_TABLE = { # *** [type_name: type_id] *** +# 'default': 'Net', +# 'atomClass': 'Atom_Class_Net', +# 'individual': 'Individual_Net', +# 'atomProperty': 'Atom_Property_Net', +# 'phenomena': 'Phenomena_Net' +# } + +# PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** +# 'structure': 'hasStructure', + +# 'class_name': 'hasClassName', + +# 'mother_class_net': 'hasMotherClassNet', +# 'individual_label': 'hasIndividualLabel', + +# 'core_role': 'isCoreRoleLinked', +# 'target_argument_node': 'targetArgumentNode', +# 'property_type': 'hasPropertyType', +# 'property_name': 'hasPropertyName', +# 'property_name01': 'hasPropertyName01', +# 'property_name10': 'hasPropertyName10', +# 'property_name12': 'hasPropertyName12', + +# 'phenomena_type': 'hasPhenomenaType', +# 'phenomena_ref': 'hasPhenomenaRef' +# } + +# -- Default Value(s) + +DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' + + +# -- Useful Constant(s) + +TRIPLE_ENDING_STR = '\n ' + + + +#============================================================================== +# Net Class +#============================================================================== + +class AtomClassNet(Net): + """ Class to generate SPARQL query parts related to semantic nets. + """ + + predicate_table = Net.predicate_table + predicate_table.update({ + 'class_name': 'hasClassName' + }) + + #-------------------------------------------------------------------------- + # Constructor(s) + #-------------------------------------------------------------------------- + + def __init__(self, num=''): + + super().__init__(num) + + # -- Net Signature + self.type_name = 'atomClass' + self.type_id = 'Atom_Class_Net' + self.id = f'?{self.type_name}Net{num}' + self.type_uri = f'net:{self.type_id}' + + # -- Net Attributes + self.class_name = f'{self.id}ClassName' + self.mother_class_net = f'{self.id}MotherClassNet' + self.individual_label = f'{self.id}IndividualLabel' + + + #-------------------------------------------------------------------------- + # Private data accessor(s) + #-------------------------------------------------------------------------- + + # def __get_predicate(self, data_ref): + # property_name = PREDICATE_TABLE[f'{data_ref}'] + # return f'net:{property_name}' + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Construct' parts + #-------------------------------------------------------------------------- + + def construct(self, **net_attribute): + query_code = super().construct(**net_attribute) + return query_code + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Clause' parts + #-------------------------------------------------------------------------- + + + + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Binding' parts + #-------------------------------------------------------------------------- + + def bind_uri(self, net_name='nameless', node_reference='00'): + return super().bind_uri(net_name, node_reference) + + + +#============================================================================== +# Development Test +#============================================================================== + +if __name__ == '__main__': + + print('\n' + ' *** Development Test ***') + + print('\n' + ' -- test: Atom Class Net') + atom_class_net = AtomClassNet() + print(atom_class_net) + + + print('\n' + ' -- test: construct') + construct_ctr = atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel') + print(construct_ctr) + + print('\n' + ' -- test: update a test query') + test_query= f"""[...] + CONSTRUCT {{ + {atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel')} + + {atom_class_net.propagate_relations()} + + }} + WHERE {{ + clause_1 + clause_2 + + {atom_class_net.identify_relations_for_propagation('?node1')} + + {atom_class_net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} + }} + """ + print(test_query) + + print('\n' + ' *** - ***') \ No newline at end of file diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/individual_net.py b/structure/cts/amr_ctr/transduction/query_builder/element/individual_net.py new file mode 100644 index 00000000..a66696b5 --- /dev/null +++ b/structure/cts/amr_ctr/transduction/query_builder/element/individual_net.py @@ -0,0 +1,173 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Net Query Builder +#------------------------------------------------------------------------------ +# Class to generate SPARQL query parts related to semantic nets +#============================================================================== + +#============================================================================== +# Importing required modules +#============================================================================== + +from net import Net + + +#============================================================================== +# Data Repository +#============================================================================== + +# -- Reference Table + +# NET_TYPE_TABLE = { # *** [type_name: type_id] *** +# 'default': 'Net', +# 'atomClass': 'Atom_Class_Net', +# 'individual': 'Individual_Net', +# 'atomProperty': 'Atom_Property_Net', +# 'phenomena': 'Phenomena_Net' +# } + +# PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** +# 'structure': 'hasStructure', + +# 'class_name': 'hasClassName', + +# 'mother_class_net': 'hasMotherClassNet', +# 'individual_label': 'hasIndividualLabel', + +# 'core_role': 'isCoreRoleLinked', +# 'target_argument_node': 'targetArgumentNode', +# 'property_type': 'hasPropertyType', +# 'property_name': 'hasPropertyName', +# 'property_name01': 'hasPropertyName01', +# 'property_name10': 'hasPropertyName10', +# 'property_name12': 'hasPropertyName12', + +# 'phenomena_type': 'hasPhenomenaType', +# 'phenomena_ref': 'hasPhenomenaRef' +# } + +# -- Default Value(s) + +DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' + + +# -- Useful Constant(s) + +TRIPLE_ENDING_STR = '\n ' + + + +#============================================================================== +# Net Class +#============================================================================== + +class IndividualNet(Net): + """ Class to generate SPARQL query parts related to semantic nets. + """ + + predicate_table = Net.predicate_table + predicate_table.update({ + 'class_name': 'hasClassName', + 'mother_class_net': 'hasMotherClassNet', + 'individual_label': 'hasIndividualLabel' + }) + + #-------------------------------------------------------------------------- + # Constructor(s) + #-------------------------------------------------------------------------- + + def __init__(self, num=''): + + super().__init__(num) + + # -- Net Signature + self.type_name = 'atomClass' + self.type_id = 'Atom_Class_Net' + self.id = f'?{self.type_name}Net{num}' + self.type_uri = f'net:{self.type_id}' + + # -- Net Attributes + self.class_name = f'{self.id}ClassName' + self.mother_class_net = f'{self.id}MotherClassNet' + self.individual_label = f'{self.id}IndividualLabel' + + + #-------------------------------------------------------------------------- + # Private data accessor(s) + #-------------------------------------------------------------------------- + + # def __get_predicate(self, data_ref): + # property_name = PREDICATE_TABLE[f'{data_ref}'] + # return f'net:{property_name}' + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Construct' parts + #-------------------------------------------------------------------------- + + def construct(self, **net_attribute): + query_code = super().construct(**net_attribute) + return query_code + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Clause' parts + #-------------------------------------------------------------------------- + + + + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Binding' parts + #-------------------------------------------------------------------------- + + def bind_uri(self, net_name='nameless', node_reference='00'): + return super().bind_uri(net_name, node_reference) + + + +#============================================================================== +# Development Test +#============================================================================== + +if __name__ == '__main__': + + print('\n' + ' *** Development Test ***') + + print('\n' + ' -- test: Atom Class Net') + net = IndividualNet() + print(net) + + + print('\n' + ' -- test: construct') + construct_ctr = net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel') + print(construct_ctr) + + print('\n' + ' -- test: update a test query') + test_query= f"""[...] + CONSTRUCT {{ + {net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel')} + + {net.propagate_relations()} + + }} + WHERE {{ + clause_1 + clause_2 + + {net.identify_relations_for_propagation('?node1')} + + {net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} + }} + """ + print(test_query) + + print('\n' + ' *** - ***') \ No newline at end of file diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/net.py b/structure/cts/amr_ctr/transduction/query_builder/element/net.py index e97d2c8a..144773af 100644 --- a/structure/cts/amr_ctr/transduction/query_builder/element/net.py +++ b/structure/cts/amr_ctr/transduction/query_builder/element/net.py @@ -20,33 +20,33 @@ # -- Reference Table -NET_TYPE_TABLE = { # *** [type_name: type_id] *** - 'default': 'Net', - 'atomClass': 'Atom_Class_Net', - 'individual': 'Individual_Net', - 'atomProperty': 'Atom_Property_Net', - 'phenomena': 'Phenomena_Net' - } - -PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** - 'structure': 'hasStructure', - - 'class_name': 'hasClassName', - - 'mother_class_net': 'hasMotherClassNet', - 'individual_label': 'hasIndividualLabel', - - 'core_role': 'isCoreRoleLinked', - 'target_argument_node': 'targetArgumentNode', - 'property_type': 'hasPropertyType', - 'property_name': 'hasPropertyName', - 'property_name01': 'hasPropertyName01', - 'property_name10': 'hasPropertyName10', - 'property_name12': 'hasPropertyName12', - - 'phenomena_type': 'hasPhenomenaType', - 'phenomena_ref': 'hasPhenomenaRef' - } +# NET_TYPE_TABLE = { # *** [type_name: type_id] *** +# 'default': 'Net', +# 'atomClass': 'Atom_Class_Net', +# 'individual': 'Individual_Net', +# 'atomProperty': 'Atom_Property_Net', +# 'phenomena': 'Phenomena_Net' +# } + +# PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** +# 'structure': 'hasStructure', + +# 'class_name': 'hasClassName', + +# 'mother_class_net': 'hasMotherClassNet', +# 'individual_label': 'hasIndividualLabel', + +# 'core_role': 'isCoreRoleLinked', +# 'target_argument_node': 'targetArgumentNode', +# 'property_type': 'hasPropertyType', +# 'property_name': 'hasPropertyName', +# 'property_name01': 'hasPropertyName01', +# 'property_name10': 'hasPropertyName10', +# 'property_name12': 'hasPropertyName12', + +# 'phenomena_type': 'hasPhenomenaType', +# 'phenomena_ref': 'hasPhenomenaRef' +# } # -- Default Value(s) @@ -55,7 +55,7 @@ DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' # -- Useful Constant(s) -TRIPLE_ENDING_STR = '\n ' +INDENT_STR = ' ' @@ -66,24 +66,27 @@ TRIPLE_ENDING_STR = '\n ' class Net: """ Class to generate SPARQL query parts related to semantic nets. """ + + predicate_table = { # *** [attribute_reference: attribute_predicate] *** + 'base_node': 'coverBaseNode', + 'structure': 'hasStructure' + } #-------------------------------------------------------------------------- # Constructor(s) #-------------------------------------------------------------------------- - def __init__(self, type_name='default', num=''): + def __init__(self, num=''): # -- Net Signature - self.id = f'?{type_name}Net{num}' - self.type_name = type_name - self.type_uri = f'net:{NET_TYPE_TABLE[type_name]}' + self.type_name = 'default' + self.type_id = 'Net' + self.id = f'?{self.type_name}Net{num}' + self.type_uri = f'net:{self.type_id}' # -- Net Attributes self.base_node = f'{self.id}BaseNode' self.structure = f'{self.id}Structure' - self.class_name = f'{self.id}ClassName' - self.mother_class_net = f'{self.id}MotherClassNet' - self.individual_label = f'{self.id}IndividualLabel' # -- Private elements (for relation propagation) self._in_relation_role = f'{self.id}InRelationRole' @@ -96,43 +99,43 @@ class Net: # Private data accessor(s) #-------------------------------------------------------------------------- - def __get_predicate(self, data_ref): - property_name = PREDICATE_TABLE[f'{data_ref}'] - return f'net:{property_name}' + def __get_predicate(self, attribute_reference): + predicate_reference = self.predicate_table[f'{attribute_reference}'] + return f'net:{predicate_reference}' #-------------------------------------------------------------------------- # Method(s) to build 'Construct' parts #-------------------------------------------------------------------------- - def __construct_attribute_triples(self, **net_attribute): + def __define_attribute_triples(self, **net_attribute): - result_triples = "" - - # -- construct triples with declared attributes - for attr_ref, attr_value in net_attribute.items(): - predicate = self.__get_predicate(attr_ref) - result_triples += f"{self.id} {predicate} {attr_value}." - result_triples += f"{TRIPLE_ENDING_STR}" + query_code = "" # -- construct triples with default object for non-declared attributes - result_triples += f"# *** default values for attribute useless *** " - result_triples += f"{TRIPLE_ENDING_STR}" - for attr_ref in PREDICATE_TABLE.keys(): - if attr_ref not in net_attribute.keys(): - predicate = self.__get_predicate(attr_ref) - result_triples += f"{self.id} {predicate} {DEFAULT_ATTRIBUTE_VALUE}." - result_triples += f"{TRIPLE_ENDING_STR}" + for attr_ref in self.predicate_table.keys(): + + predicate = self.__get_predicate(attr_ref) + + if attr_ref in net_attribute.keys(): + attr_value = net_attribute.get(attr_ref) + comment = '' + else: + attr_value = DEFAULT_ATTRIBUTE_VALUE + comment = ' # *** attribute useless ***' + + query_code += f"{self.id} {predicate} {attr_value}.{comment}" + query_code += f"\n{INDENT_STR}" - return result_triples + return query_code - def construct(self, base_node, **net_attribute): + def define_new_net(self, **net_attribute): + net_attribute.update({'structure': '?sentenceRef'}) return f""" # -- New Net {self.id} a {self.type_uri}. - {self.id} net:coverBaseNode {base_node}. - {self.__construct_attribute_triples(**net_attribute)}""" + {self.__define_attribute_triples(**net_attribute)}""" def propagate_relations(self): @@ -142,13 +145,26 @@ class Net: {self._in_net} {self._in_relation_role} {self.id}. {self._out_relation_role} a net:Relation. {self.id} {self._out_relation_role} {self._out_net}.""" + + + def construct(self, **net_attribute): + query_code = self.define_new_net(**net_attribute) + query_code += self.propagate_relations() + return query_code #-------------------------------------------------------------------------- - # Method(s) to build 'Clause' parts + # Method(s) to build 'Complement Clause' parts #-------------------------------------------------------------------------- + def identify_structure(self): + return f""" + # -- Identify structure + ?root a amr:AMR_Root. + ?root amr:hasSentenceID ?sentenceRef. + """ + def identify_relations_for_propagation(self, base_node): return f""" # -- Identify inbound relations linked to the base leaf (for propagation) @@ -168,6 +184,11 @@ class Net: }} """ + def complete_clauses_for_construction(self, base_node): + query_code = self.identify_structure() + query_code += self.identify_relations_for_propagation(base_node) + return query_code + #-------------------------------------------------------------------------- @@ -200,34 +221,23 @@ if __name__ == '__main__': print('\n' + ' *** Development Test ***') print('\n' + ' -- test: Atom Class Net') - atom_class_net = Net('atomClass') - print(atom_class_net) - - - print('\n' + ' -- test: construct') - construct_ctr = atom_class_net.construct('?node1', - structure='?structureRef', - class_name='?leaf1ConceptLabel') - print(construct_ctr) + net = Net() + print(net) print('\n' + ' -- test: update a test query') test_query= f"""[...] CONSTRUCT {{ - {atom_class_net.construct('?node1', - structure='?structureRef', - class_name='?leaf1ConceptLabel')} - - {atom_class_net.propagate_relations()} + {net.construct(base_node='?node1')} }} WHERE {{ clause_1 clause_2 - {atom_class_net.identify_relations_for_propagation('?node1')} + {net.complete_clauses_for_construction('?node1')} - {atom_class_net.bind_uri('{{node1.concept_label}}', - '{{node1.variable_label}}')} + {net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} }} """ print(test_query) diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/old_net.py b/structure/cts/amr_ctr/transduction/query_builder/element/old_net.py new file mode 100644 index 00000000..c1b09f6d --- /dev/null +++ b/structure/cts/amr_ctr/transduction/query_builder/element/old_net.py @@ -0,0 +1,235 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Net Query Builder +#------------------------------------------------------------------------------ +# Class to generate SPARQL query parts related to semantic nets +#============================================================================== + +#============================================================================== +# Importing required modules +#============================================================================== + +# -- + + +#============================================================================== +# Data Repository +#============================================================================== + +# -- Reference Table + +NET_TYPE_TABLE = { # *** [type_name: type_id] *** + 'default': 'Net', + 'atomClass': 'Atom_Class_Net', + 'individual': 'Individual_Net', + 'atomProperty': 'Atom_Property_Net', + 'phenomena': 'Phenomena_Net' + } + +PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** + 'structure': 'hasStructure', + + 'class_name': 'hasClassName', + + 'mother_class_net': 'hasMotherClassNet', + 'individual_label': 'hasIndividualLabel', + + 'core_role': 'isCoreRoleLinked', + 'target_argument_node': 'targetArgumentNode', + 'property_type': 'hasPropertyType', + 'property_name': 'hasPropertyName', + 'property_name01': 'hasPropertyName01', + 'property_name10': 'hasPropertyName10', + 'property_name12': 'hasPropertyName12', + + 'phenomena_type': 'hasPhenomenaType', + 'phenomena_ref': 'hasPhenomenaRef' + } + +# -- Default Value(s) + +DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' + + +# -- Useful Constant(s) + +TRIPLE_ENDING_STR = '\n ' + + + +#============================================================================== +# Net Class +#============================================================================== + +class OldNet: + """ Class to generate SPARQL query parts related to semantic nets. + """ + + #-------------------------------------------------------------------------- + # Constructor(s) + #-------------------------------------------------------------------------- + + def __init__(self, type_name='default', num=''): + + # -- Net Signature + self.id = f'?{type_name}Net{num}' + self.type_name = type_name + self.type_uri = f'net:{NET_TYPE_TABLE[type_name]}' + + # -- Net Attributes + self.base_node = f'{self.id}BaseNode' + self.structure = f'{self.id}Structure' + self.class_name = f'{self.id}ClassName' + self.mother_class_net = f'{self.id}MotherClassNet' + self.individual_label = f'{self.id}IndividualLabel' + + # -- Private elements (for relation propagation) + self._in_relation_role = f'{self.id}InRelationRole' + self._in_net = f'{self.id}InNet' + self._out_relation_role = f'{self.id}OutRelationRole' + self._out_net = f'{self.id}OutNet' + + + #-------------------------------------------------------------------------- + # Private data accessor(s) + #-------------------------------------------------------------------------- + + def __get_predicate(self, data_ref): + property_name = PREDICATE_TABLE[f'{data_ref}'] + return f'net:{property_name}' + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Construct' parts + #-------------------------------------------------------------------------- + + def __construct_attribute_triples(self, **net_attribute): + + result_triples = "" + + # -- construct triples with declared attributes + for attr_ref, attr_value in net_attribute.items(): + predicate = self.__get_predicate(attr_ref) + result_triples += f"{self.id} {predicate} {attr_value}." + result_triples += f"{TRIPLE_ENDING_STR}" + + # -- construct triples with default object for non-declared attributes + result_triples += f"# *** default values for attribute useless *** " + result_triples += f"{TRIPLE_ENDING_STR}" + for attr_ref in PREDICATE_TABLE.keys(): + if attr_ref not in net_attribute.keys(): + predicate = self.__get_predicate(attr_ref) + result_triples += f"{self.id} {predicate} {DEFAULT_ATTRIBUTE_VALUE}." + result_triples += f"{TRIPLE_ENDING_STR}" + + return result_triples + + + def construct(self, base_node, **net_attribute): + return f""" + # -- New Net + {self.id} a {self.type_uri}. + {self.id} net:coverBaseNode {base_node}. + {self.__construct_attribute_triples(**net_attribute)}""" + + + def propagate_relations(self): + return f""" + # -- Propagation of relations (from nodes to nets) + {self._in_relation_role} a net:Relation. + {self._in_net} {self._in_relation_role} {self.id}. + {self._out_relation_role} a net:Relation. + {self.id} {self._out_relation_role} {self._out_net}.""" + + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Clause' parts + #-------------------------------------------------------------------------- + + def identify_relations_for_propagation(self, base_node): + return f""" + # -- Identify inbound relations linked to the base leaf (for propagation) + OPTIONAL {{ + {self._in_net} a [rdfs:subClassOf* net:Net] ; + net:coverBaseNode ?inLeaf. + ?inLeaf ?inRelationEdge {base_node}. + ?inRelationEdge amr:hasAmrRole {self._in_relation_role}. + }} + + # -- Identify outgoing relations linked to the base leaf (for propagation) + OPTIONAL {{ + {self._out_net} a [rdfs:subClassOf* net:Net] ; + net:coverBaseNode ?outLeaf. + {base_node} ?outRelationEdge ?outLeaf. + ?outRelationEdge amr:hasAmrRole {self._out_relation_role}. + }} + """ + + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Binding' parts + #-------------------------------------------------------------------------- + + def bind_uri(self, net_name='nameless', node_reference='00'): + ref1 = f"{self.id}Ref1" + ref2 = f"{self.id}Ref2" + ref3 = f"{self.id}Ref3" + refNet = f"{net_name}RefNet" + refNode = f"{node_reference}RefNode" + return f""" + # -- New Net + BIND (REPLACE({net_name}, ' ', "") AS {refNet}). + BIND (REPLACE({node_reference}, ' ', "") AS {refNode}). + BIND (CONCAT(str(net:), '{self.type_name}') AS {ref1}). + BIND (CONCAT({ref1}, '_', {refNet}) AS {ref2}). + BIND (CONCAT({ref2}, '_', {refNode}) AS {ref3}). + BIND (uri({ref3}) AS {self.id}).""" + + + +#============================================================================== +# Development Test +#============================================================================== + +if __name__ == '__main__': + + print('\n' + ' *** Development Test ***') + + print('\n' + ' -- test: Atom Class Net') + atom_class_net = Net('atomClass') + print(atom_class_net) + + + print('\n' + ' -- test: construct') + construct_ctr = atom_class_net.construct('?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel') + print(construct_ctr) + + print('\n' + ' -- test: update a test query') + test_query= f"""[...] + CONSTRUCT {{ + {atom_class_net.construct('?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel')} + + {atom_class_net.propagate_relations()} + + }} + WHERE {{ + clause_1 + clause_2 + + {atom_class_net.identify_relations_for_propagation('?node1')} + + {atom_class_net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} + }} + """ + print(test_query) + + print('\n' + ' *** - ***') diff --git a/structure/cts/amr_ctr/transduction/query_builder/element/phenomena_net.py b/structure/cts/amr_ctr/transduction/query_builder/element/phenomena_net.py new file mode 100644 index 00000000..c8cb2bd7 --- /dev/null +++ b/structure/cts/amr_ctr/transduction/query_builder/element/phenomena_net.py @@ -0,0 +1,171 @@ +#!/usr/bin/python3.10 +# -*-coding:Utf-8 -* + +#============================================================================== +# TENET: Net Query Builder +#------------------------------------------------------------------------------ +# Class to generate SPARQL query parts related to semantic nets +#============================================================================== + +#============================================================================== +# Importing required modules +#============================================================================== + +from net import Net + + +#============================================================================== +# Data Repository +#============================================================================== + +# -- Reference Table + +# NET_TYPE_TABLE = { # *** [type_name: type_id] *** +# 'default': 'Net', +# 'atomClass': 'Atom_Class_Net', +# 'individual': 'Individual_Net', +# 'atomProperty': 'Atom_Property_Net', +# 'phenomena': 'Phenomena_Net' +# } + +# PREDICATE_TABLE = { # *** [attribute_reference: attribute_predicate] *** +# 'structure': 'hasStructure', + +# 'class_name': 'hasClassName', + +# 'mother_class_net': 'hasMotherClassNet', +# 'individual_label': 'hasIndividualLabel', + +# 'core_role': 'isCoreRoleLinked', +# 'target_argument_node': 'targetArgumentNode', +# 'property_type': 'hasPropertyType', +# 'property_name': 'hasPropertyName', +# 'property_name01': 'hasPropertyName01', +# 'property_name10': 'hasPropertyName10', +# 'property_name12': 'hasPropertyName12', + +# 'phenomena_type': 'hasPhenomenaType', +# 'phenomena_ref': 'hasPhenomenaRef' +# } + +# -- Default Value(s) + +DEFAULT_ATTRIBUTE_VALUE = f'\"NA\"' + + +# -- Useful Constant(s) + +TRIPLE_ENDING_STR = '\n ' + + + +#============================================================================== +# Net Class +#============================================================================== + +class AtomClassNet(Net): + """ Class to generate SPARQL query parts related to semantic nets. + """ + + predicate_table = Net.predicate_table + predicate_table.update({ + 'class_name': 'hasClassName' + }) + + #-------------------------------------------------------------------------- + # Constructor(s) + #-------------------------------------------------------------------------- + + def __init__(self, num=''): + + super().__init__(num) + + # -- Net Signature + self.type_name = 'atomClass' + self.type_id = 'Atom_Class_Net' + self.id = f'?{self.type_name}Net{num}' + self.type_uri = f'net:{self.type_id}' + + # -- Net Attributes + self.class_name = f'{self.id}ClassName' + self.mother_class_net = f'{self.id}MotherClassNet' + self.individual_label = f'{self.id}IndividualLabel' + + + #-------------------------------------------------------------------------- + # Private data accessor(s) + #-------------------------------------------------------------------------- + + # def __get_predicate(self, data_ref): + # property_name = PREDICATE_TABLE[f'{data_ref}'] + # return f'net:{property_name}' + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Construct' parts + #-------------------------------------------------------------------------- + + def construct(self, **net_attribute): + query_code = super().construct(**net_attribute) + return query_code + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Clause' parts + #-------------------------------------------------------------------------- + + + + + + #-------------------------------------------------------------------------- + # Method(s) to build 'Binding' parts + #-------------------------------------------------------------------------- + + def bind_uri(self, net_name='nameless', node_reference='00'): + return super().bind_uri(net_name, node_reference) + + + +#============================================================================== +# Development Test +#============================================================================== + +if __name__ == '__main__': + + print('\n' + ' *** Development Test ***') + + print('\n' + ' -- test: Atom Class Net') + atom_class_net = AtomClassNet() + print(atom_class_net) + + + print('\n' + ' -- test: construct') + construct_ctr = atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel') + print(construct_ctr) + + print('\n' + ' -- test: update a test query') + test_query= f"""[...] + CONSTRUCT {{ + {atom_class_net.construct(base_node='?node1', + structure='?structureRef', + class_name='?leaf1ConceptLabel')} + + {atom_class_net.propagate_relations()} + + }} + WHERE {{ + clause_1 + clause_2 + + {atom_class_net.identify_relations_for_propagation('?node1')} + + {atom_class_net.bind_uri('{{node1.concept_label}}', + '{{node1.variable_label}}')} + }} + """ + print(test_query) + + print('\n' + ' *** - ***') \ No newline at end of file diff --git a/tenet.log b/tenet.log index b2d8487b..d5c463ce 100644 --- a/tenet.log +++ b/tenet.log @@ -23,8 +23,8 @@ ----- CTS directory: ./structure/cts/ ----- target frame directory: ./input/targetFrameStructure/ ----- input document directory: ./input/amrDocuments/ - ----- output directory: ./output/SolarSystemDev1-20221215/ - ----- sentence output directory: ./output/SolarSystemDev1-20221215/ + ----- output directory: ./output/SolarSystemDev1-20221216/ + ----- sentence output directory: ./output/SolarSystemDev1-20221216/ ----- SHACL binary directory: ./lib/shacl-1.3.2/bin -- Config File Definition ----- schema file: ./structure/amr-rdf-schema.ttl @@ -44,9 +44,9 @@ ----- frame ontology seed file: ./input/targetFrameStructure/base-ontology-seed.ttl -- Output ----- ontology namespace: https://tenet.tetras-libre.fr/base-ontology/ - ----- output file: ./output/SolarSystemDev1-20221215/SolarSystemDev1.ttl + ----- output file: ./output/SolarSystemDev1-20221216/SolarSystemDev1.ttl *** - *** -- INFO - -- Creating output target directory: ./output/SolarSystemDev1-20221215/ +- INFO - -- Creating output target directory: ./output/SolarSystemDev1-20221216/ - DEBUG - -- Counting number of graph files (sentences) - DEBUG - ----- Graph count: 1 - INFO - === Extraction Processing using New TENET Engine === @@ -64,9 +64,9 @@ - DEBUG - ----- Sentence Loading - DEBUG - -------- ./input/amrDocuments/dev/solar-system-1/SSC-01-01.stog.amr.ttl (614) - DEBUG - --- Export work graph as turtle -- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-20221215/SolarSystemDev1-1/SolarSystemDev1.ttl +- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-20221216/SolarSystemDev1-1/SolarSystemDev1.ttl - DEBUG - --- Ending Structure Preparation -- DEBUG - ----- Total Execution Time = 0:00:00.127085 +- DEBUG - ----- Total Execution Time = 0:00:00.101997 - INFO - -- Loading Extraction Scheme (amr_scheme_1) - DEBUG - ----- Step number: 3 - INFO - -- Loading Extraction Rules (amr_ctr/*) @@ -95,133 +95,133 @@ - DEBUG - --- Serializing graph to SolarSystemDev1_preprocessing - DEBUG - ----- step: preprocessing - DEBUG - ----- id: SolarSystemDev1 -- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221215/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl +- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221216/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl - DEBUG - ----- base: http://SolarSystemDev1/preprocessing - INFO - ----- 212 triples extracted during preprocessing step - INFO - -- Applying extraction step: transduction - INFO - --- Sequence: atomic-extraction-sequence -- INFO - ----- create-atom-class-net: 75/75 new triples (901) -- DEBUG - ----- (refinement) refine-cover-node-1: 5 new triples (906) -- DEBUG - ----- (refinement) refine-cover-node-2: 5 new triples (911) -- INFO - ----- create-individual-net-1: 17/17 new triples (928) -- DEBUG - ----- (refinement) refine-cover-node-1: 1 new triples (929) -- INFO - ----- create-atom-property-net-1: 99/99 new triples (1028) -- DEBUG - ----- (refinement) refine-cover-node-1: 6 new triples (1034) -- INFO - ----- create-phenomena-net-1: 40/41 new triples (1074) -- DEBUG - ----- (refinement) refine-cover-node-1: 2 new triples (1076) +- INFO - ----- create-atom-class-net: 20/20 new triples (846) +- DEBUG - ----- (refinement) refine-cover-node-1: 5 new triples (851) +- DEBUG - ----- (refinement) refine-cover-node-2: 5 new triples (856) +- INFO - ----- create-individual-net-1: 17/17 new triples (873) +- DEBUG - ----- (refinement) refine-cover-node-1: 1 new triples (874) +- INFO - ----- create-atom-property-net-1: 99/99 new triples (973) +- DEBUG - ----- (refinement) refine-cover-node-1: 6 new triples (979) +- INFO - ----- create-phenomena-net-1: 40/41 new triples (1019) +- DEBUG - ----- (refinement) refine-cover-node-1: 2 new triples (1021) - INFO - --- Sequence: atomic-extraction-sequence -- INFO - ----- create-atom-class-net: 1/89 new triples (1077) -- DEBUG - ----- create-individual-net-1: 0/17 new triples (1077) -- INFO - ----- create-atom-property-net-1: 1/106 new triples (1078) -- DEBUG - ----- create-phenomena-net-1: 0/41 new triples (1078) +- INFO - ----- create-atom-class-net: 1/34 new triples (1022) +- DEBUG - ----- create-individual-net-1: 0/17 new triples (1022) +- INFO - ----- create-atom-property-net-1: 1/106 new triples (1023) +- DEBUG - ----- create-phenomena-net-1: 0/41 new triples (1023) - INFO - --- Sequence: phenomena-checking-sequence -- INFO - ----- expand-and-conjunction-phenomena-net: 4/4 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-1: 0/0 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-2: 0/0 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-3: 0/0 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-4: 0/0 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-5: 0/0 new triples (1082) -- DEBUG - ----- expand-degree-phenomena-net-6: 0/0 new triples (1082) +- INFO - ----- expand-and-conjunction-phenomena-net: 4/4 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-1: 0/0 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-2: 0/0 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-3: 0/0 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-4: 0/0 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-5: 0/0 new triples (1027) +- DEBUG - ----- expand-degree-phenomena-net-6: 0/0 new triples (1027) - INFO - --- Sequence: composite-property-extraction-sequence -- DEBUG - ----- create-composite-class-net-from-property-1: 0/0 new triples (1082) -- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1082) +- DEBUG - ----- create-composite-class-net-from-property-1: 0/0 new triples (1027) +- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1027) - INFO - --- Sequence: composite-class-extraction-sequence-1 -- INFO - ----- create-composite-class-net-from-property-1: 75/79 new triples (1157) -- DEBUG - ----- (refinement) refine-cover-node-1: 12 new triples (1169) -- DEBUG - ----- (refinement) refine-cover-node-2: 4 new triples (1173) -- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1173) -- DEBUG - ----- create-composite-class-net-from-property-3: 0/0 new triples (1173) +- INFO - ----- create-composite-class-net-from-property-1: 75/79 new triples (1102) +- DEBUG - ----- (refinement) refine-cover-node-1: 12 new triples (1114) +- DEBUG - ----- (refinement) refine-cover-node-2: 4 new triples (1118) +- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1118) +- DEBUG - ----- create-composite-class-net-from-property-3: 0/0 new triples (1118) - INFO - --- Sequence: composite-class-extraction-sequence-2 -- DEBUG - ----- create-composite-class-net-from-phenomena-1: 0/0 new triples (1173) -- DEBUG - ----- create-composite-class-net-from-phenomena-2: 0/0 new triples (1173) -- DEBUG - ----- create-composite-class-net-from-phenomena-3: 0/0 new triples (1173) -- DEBUG - ----- create-composite-class-net-from-phenomena-4: 0/0 new triples (1173) +- DEBUG - ----- create-composite-class-net-from-phenomena-1: 0/0 new triples (1118) +- DEBUG - ----- create-composite-class-net-from-phenomena-2: 0/0 new triples (1118) +- DEBUG - ----- create-composite-class-net-from-phenomena-3: 0/0 new triples (1118) +- DEBUG - ----- create-composite-class-net-from-phenomena-4: 0/0 new triples (1118) - INFO - --- Sequence: phenomena-checking-sequence -- INFO - ----- expand-and-conjunction-phenomena-net: 1/5 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-1: 0/0 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-2: 0/0 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-3: 0/0 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-4: 0/0 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-5: 0/0 new triples (1174) -- DEBUG - ----- expand-degree-phenomena-net-6: 0/0 new triples (1174) +- INFO - ----- expand-and-conjunction-phenomena-net: 1/5 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-1: 0/0 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-2: 0/0 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-3: 0/0 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-4: 0/0 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-5: 0/0 new triples (1119) +- DEBUG - ----- expand-degree-phenomena-net-6: 0/0 new triples (1119) - INFO - --- Sequence: composite-property-extraction-sequence -- DEBUG - ----- create-composite-class-net-from-property-1: 0/0 new triples (1174) -- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1174) +- DEBUG - ----- create-composite-class-net-from-property-1: 0/0 new triples (1119) +- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1119) - INFO - --- Sequence: composite-class-extraction-sequence-1 -- INFO - ----- create-composite-class-net-from-property-1: 94/173 new triples (1268) -- DEBUG - ----- (refinement) refine-cover-node-1: 15 new triples (1283) -- DEBUG - ----- (refinement) refine-cover-node-2: 5 new triples (1288) -- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1288) -- DEBUG - ----- create-composite-class-net-from-property-3: 0/0 new triples (1288) +- INFO - ----- create-composite-class-net-from-property-1: 94/173 new triples (1213) +- DEBUG - ----- (refinement) refine-cover-node-1: 15 new triples (1228) +- DEBUG - ----- (refinement) refine-cover-node-2: 5 new triples (1233) +- DEBUG - ----- create-composite-class-net-from-property-2: 0/0 new triples (1233) +- DEBUG - ----- create-composite-class-net-from-property-3: 0/0 new triples (1233) - INFO - --- Sequence: composite-class-extraction-sequence-2 -- DEBUG - ----- create-composite-class-net-from-phenomena-1: 0/0 new triples (1288) -- DEBUG - ----- create-composite-class-net-from-phenomena-2: 0/0 new triples (1288) -- DEBUG - ----- create-composite-class-net-from-phenomena-3: 0/0 new triples (1288) -- DEBUG - ----- create-composite-class-net-from-phenomena-4: 0/0 new triples (1288) +- DEBUG - ----- create-composite-class-net-from-phenomena-1: 0/0 new triples (1233) +- DEBUG - ----- create-composite-class-net-from-phenomena-2: 0/0 new triples (1233) +- DEBUG - ----- create-composite-class-net-from-phenomena-3: 0/0 new triples (1233) +- DEBUG - ----- create-composite-class-net-from-phenomena-4: 0/0 new triples (1233) - INFO - --- Sequence: restriction-adding-sequence -- DEBUG - ----- add-restriction-to-class-net-from-property-1: 0/0 new triples (1288) +- DEBUG - ----- add-restriction-to-class-net-from-property-1: 0/0 new triples (1233) - INFO - --- Sequence: classification-sequence -- INFO - ----- classify-net-from-core-1: 12/12 new triples (1300) -- INFO - ----- classify-net-from-core-2: 1/9 new triples (1301) -- DEBUG - ----- classify-net-from-core-3: 0/0 new triples (1301) -- DEBUG - ----- classify-net-from-mod: 0/0 new triples (1301) -- DEBUG - ----- classify-net-from-part: 0/0 new triples (1301) -- INFO - ----- classify-net-from-domain: 6/6 new triples (1307) -- DEBUG - ----- classify-net-from-degree-phenomena-1: 0/0 new triples (1307) -- DEBUG - ----- classify-net-from-degree-phenomena-2: 0/0 new triples (1307) -- DEBUG - ----- classify-net-from-degree-phenomena-3: 0/0 new triples (1307) -- DEBUG - ----- propagate-individual-1: 0/1 new triples (1307) -- INFO - ----- propagate-individual-2: 6/6 new triples (1313) -- DEBUG - ----- reclassify-deprecated-net: 0/0 new triples (1313) +- INFO - ----- classify-net-from-core-1: 12/12 new triples (1245) +- INFO - ----- classify-net-from-core-2: 1/9 new triples (1246) +- DEBUG - ----- classify-net-from-core-3: 0/0 new triples (1246) +- DEBUG - ----- classify-net-from-mod: 0/0 new triples (1246) +- DEBUG - ----- classify-net-from-part: 0/0 new triples (1246) +- INFO - ----- classify-net-from-domain: 6/6 new triples (1252) +- DEBUG - ----- classify-net-from-degree-phenomena-1: 0/0 new triples (1252) +- DEBUG - ----- classify-net-from-degree-phenomena-2: 0/0 new triples (1252) +- DEBUG - ----- classify-net-from-degree-phenomena-3: 0/0 new triples (1252) +- DEBUG - ----- propagate-individual-1: 0/1 new triples (1252) +- INFO - ----- propagate-individual-2: 6/6 new triples (1258) +- DEBUG - ----- reclassify-deprecated-net: 0/0 new triples (1258) - DEBUG - --- Serializing graph to SolarSystemDev1_transduction - DEBUG - ----- step: transduction - DEBUG - ----- id: SolarSystemDev1 -- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221215/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl +- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221216/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl - DEBUG - ----- base: http://SolarSystemDev1/transduction -- INFO - ----- 487 triples extracted during transduction step +- INFO - ----- 432 triples extracted during transduction step - INFO - -- Applying extraction step: generation - INFO - --- Sequence: main-generation-sequence -- INFO - ----- compute-uri-for-owl-declaration-1: 14/14 new triples (1327) -- INFO - ----- compute-uri-for-owl-declaration-2: 1/1 new triples (1328) -- DEBUG - ----- compute-uri-for-owl-declaration-4: 0/0 new triples (1328) -- INFO - ----- compute-uri-for-owl-declaration-5: 6/6 new triples (1334) -- INFO - ----- compute-uri-for-owl-declaration-6: 6/6 new triples (1340) -- INFO - ----- generate-atom-class: 12/12 new triples (1352) -- INFO - ----- classify-atom-class-1: 4/4 new triples (1356) -- INFO - ----- classify-atom-class-2: 1/1 new triples (1357) -- INFO - ----- generate-individual: 3/3 new triples (1360) -- INFO - ----- classify-individual: 6/6 new triples (1366) -- INFO - ----- generate-atom-property-1: 20/20 new triples (1386) -- INFO - ----- generate-atom-property-12: 12/20 new triples (1398) -- DEBUG - ----- generate-inverse-relation: 0/0 new triples (1398) -- INFO - ----- generate-composite-class: 38/38 new triples (1436) -- DEBUG - ----- add-restriction-to-class-1: 0/0 new triples (1436) -- DEBUG - ----- add-restriction-to-class-2: 0/0 new triples (1436) -- INFO - ----- add-restriction-to-class-3: 36/45 new triples (1472) -- DEBUG - ----- add-restriction-to-class-4: 0/0 new triples (1472) -- DEBUG - ----- add-restriction-to-class-5: 0/0 new triples (1472) -- DEBUG - ----- add-restriction-to-class-6: 0/0 new triples (1472) -- DEBUG - ----- generate-composite-property: 0/0 new triples (1472) +- INFO - ----- compute-uri-for-owl-declaration-1: 14/14 new triples (1272) +- INFO - ----- compute-uri-for-owl-declaration-2: 1/1 new triples (1273) +- DEBUG - ----- compute-uri-for-owl-declaration-4: 0/0 new triples (1273) +- INFO - ----- compute-uri-for-owl-declaration-5: 6/6 new triples (1279) +- INFO - ----- compute-uri-for-owl-declaration-6: 6/6 new triples (1285) +- INFO - ----- generate-atom-class: 12/12 new triples (1297) +- INFO - ----- classify-atom-class-1: 4/4 new triples (1301) +- INFO - ----- classify-atom-class-2: 1/1 new triples (1302) +- INFO - ----- generate-individual: 3/3 new triples (1305) +- INFO - ----- classify-individual: 6/6 new triples (1311) +- INFO - ----- generate-atom-property-1: 20/20 new triples (1331) +- INFO - ----- generate-atom-property-12: 12/20 new triples (1343) +- DEBUG - ----- generate-inverse-relation: 0/0 new triples (1343) +- INFO - ----- generate-composite-class: 38/38 new triples (1381) +- DEBUG - ----- add-restriction-to-class-1: 0/0 new triples (1381) +- DEBUG - ----- add-restriction-to-class-2: 0/0 new triples (1381) +- INFO - ----- add-restriction-to-class-3: 36/45 new triples (1417) +- DEBUG - ----- add-restriction-to-class-4: 0/0 new triples (1417) +- DEBUG - ----- add-restriction-to-class-5: 0/0 new triples (1417) +- DEBUG - ----- add-restriction-to-class-6: 0/0 new triples (1417) +- DEBUG - ----- generate-composite-property: 0/0 new triples (1417) - DEBUG - --- Serializing graph to SolarSystemDev1_generation - DEBUG - ----- step: generation - DEBUG - ----- id: SolarSystemDev1 -- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221215/SolarSystemDev1-1/SolarSystemDev1_generation.ttl +- DEBUG - ----- work_file: ./output/SolarSystemDev1-20221216/SolarSystemDev1-1/SolarSystemDev1_generation.ttl - DEBUG - ----- base: http://SolarSystemDev1/generation - INFO - ----- 159 triples extracted during generation step - INFO - -- Result: file containing only the factoids - DEBUG - --- Making factoid graph with the last step result - DEBUG - ----- Number of factoids: 176 - DEBUG - ----- Graph base: http://SolarSystemDev1/factoid -- DEBUG - --- Serializing graph to factoid file (./output/SolarSystemDev1-20221215/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl) +- DEBUG - --- Serializing graph to factoid file (./output/SolarSystemDev1-20221216/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl) - INFO - *** Execution Time *** ----- Function: apply (lib.tenet_extraction) ------ Total Time: 0:00:07.567600 ------ Process Time: 0:00:07.544648 +----- Total Time: 0:00:06.370078 +----- Process Time: 0:00:06.357116 *** - *** - INFO - === Final Ontology Generation === - INFO - -- Making complete factoid graph by merging sentence factoid graphs - INFO - ----- Total factoid number: 176 - INFO - ----- Graph base: http://SolarSystemDev1/factoid -- INFO - -- Serializing graph to factoid file (./output/SolarSystemDev1-20221215/SolarSystemDev1_factoid.ttl) +- INFO - -- Serializing graph to factoid file (./output/SolarSystemDev1-20221216/SolarSystemDev1_factoid.ttl) - INFO - === Done === -- GitLab