Skip to content
Snippets Groups Projects
Commit 32090036 authored by Aurélien Lamercerie's avatar Aurélien Lamercerie
Browse files

New AMR Rule: transduction.atom_relation_propagator

parent e739ffef
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ from scheme.amr_rule.transduction.atom_individual_extractor import *
from scheme.amr_rule.transduction.atom_property_extractor import *
from scheme.amr_rule.transduction.atom_value_extractor import *
from scheme.amr_rule.transduction.atom_phenomena_extractor import *
from scheme.amr_rule.transduction.atom_relation_propagator import *
from scheme.amr_rule.transduction.composite_class_extractor_1 import *
......
......@@ -114,7 +114,7 @@ def __construct_atom_class_net(graph, leaf, concept_name):
atom_class_net.naming = concept_name
# -- Relation Propagation
__propagate_relation(graph, atom_class_net, leaf)
# __propagate_relation(graph, atom_class_net, leaf)
# -- Finalization
atom_class_net.finalize()
......
......@@ -135,7 +135,7 @@ def __construct_individual_net(
individual_net.naming = __define_naming(value_label)
# -- Relation Propagation
__propagate_relation(graph, individual_net, base_leaf)
# __propagate_relation(graph, individual_net, base_leaf)
# -- Finalization
individual_net.finalize()
......
......@@ -119,7 +119,7 @@ def __construct_phenomena_net(
phenomena_net.naming = phenomena_label
# -- Relation Propagation
__propagate_relation(graph, phenomena_net, base_leaf)
# __propagate_relation(graph, phenomena_net, base_leaf)
# -- Finalization
phenomena_net.finalize()
......
......@@ -148,7 +148,7 @@ def __construct_atom_property_net(graph, base_leaf, predicate_label):
atom_property_net.property_name12 = f'{naming}-of'
# -- Relation Propagation
__propagate_relation(graph, atom_property_net, base_leaf)
# __propagate_relation(graph, atom_property_net, base_leaf)
# -- Finalization
atom_property_net.finalize()
......
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Rule to extract atomic individuals
#------------------------------------------------------------------------------
# Net Expansion AMR rule to extract atomic individuals
# Rule: leaf{variable, concept} => atomicClass
#==============================================================================
from rdflib import Graph
import transduction
from transduction import net
from transduction.query_builder import generate_select_query
from transduction.naming_computer import define_composite_naming_1, define_restriction_naming
#==============================================================================
# Pattern Search: Leaf{variable, concept} corresponding to individual
#==============================================================================
def __search_pattern(graph):
select_data_list = ['?net']
clause_list = [f'?net a [rdfs:subClassOf* net:Net].']
query_code = generate_select_query(graph, select_data_list, clause_list)
result_set = graph.query(query_code)
return query_code, result_set
#==============================================================================
# Useful Additional Search
#==============================================================================
def __search_leaf_in_relation(graph, base_leaf_uri):
select_data_list = ['?inRelationRole', '?inNet']
clause_list = [f'?inNet a [rdfs:subClassOf* net:Net].',
f'?inNet net:coverBaseNode ?inLeaf.',
('?inLeaf', '?relation', base_leaf_uri),
f'?relation amr:hasAmrRole ?inRelationRole.']
query_code = generate_select_query(graph, select_data_list, clause_list)
result_set = graph.query(query_code)
return query_code, result_set
def __search_leaf_out_relation(graph, base_leaf_uri):
select_data_list = ['?outRelationRole', '?outNet']
clause_list = [f'?outNet a [rdfs:subClassOf* net:Net].',
f'?outNet net:coverBaseNode ?outLeaf.',
(base_leaf_uri, '?relation', '?outLeaf'),
f'?relation amr:hasAmrRole ?outRelationRole.']
query_code = generate_select_query(graph, select_data_list, clause_list)
result_set = graph.query(query_code)
return query_code, result_set
#==============================================================================
# Useful Computation Method(s)
#==============================================================================
def __propagate_relation(graph, target_net, base_leaf):
_, in_relation_set = __search_leaf_in_relation(graph, base_leaf)
for row in in_relation_set:
target_net.input_relation_list += [(row.inNet, row.inRelationRole, _)]
_, out_relation_set = __search_leaf_out_relation(graph, base_leaf)
for row in out_relation_set:
target_net.output_relation_list += [(_, row.outRelationRole, row.outNet)]
#==============================================================================
# Main Method
#==============================================================================
def propagate_atom_relation(graph):
# -- Rule Initialization
rule_label = 'propagate atom relations'
# -- Search for patterns
_, pattern_set = __search_pattern(graph)
# -- Selection Analyzing (1)
rule_triple_list = []
for pattern in pattern_set:
target_net = net.Net(graph, pattern.net)
if len(target_net.base_node) > 0:
__propagate_relation(graph, target_net, target_net.base_node[0])
rule_triple_list += target_net.generate_net_relation_triples()
return rule_label, rule_triple_list
\ No newline at end of file
......@@ -231,7 +231,8 @@ atomic_extraction_sequence = ['atomic-extraction-sequence',
rule.extract_atom_individual,
rule.extract_atom_property,
rule.extract_atom_value,
rule.extract_atom_phenomena]
rule.extract_atom_phenomena,
rule.propagate_atom_relation]
phenomena_polarity_analyze_sequence = ['phenomena_polarity_analyze_sequence',
rule.analyze_phenomena_polarity_1]
......@@ -298,6 +299,9 @@ scheme = {
'transduction': [transduction_refinement_sequence,
atomic_extraction_sequence],
# 'transduction': [transduction_refinement_sequence,
# old_atomic_extraction_sequence],
# 'transduction': [transduction_refinement_sequence,
# old_atomic_extraction_sequence,
# old_atomic_extraction_sequence,
......
- INFO - [TENET] Extraction Processing
- INFO -
=== Process Initialization ===
- INFO - -- Process Setting
- INFO - ----- Corpus source: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-01/SSC-01-01.stog.amr.ttl (amr)
- INFO - ----- Base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/SolarSystemDev01_factoid.ttl
- INFO - ----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/
- INFO - ----- Ontology target (id): https://tenet.tetras-libre.fr/demo/01/
- INFO - ----- Current path: /home/lamenji/Workspace/Tetras/tenet/tenet
- DEBUG - ----- Config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml
- DEBUG -
*** Config (Full Parameters) ***
-- Base Parameters
----- config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml
----- uuid: https://tenet.tetras-libre.fr/demo/01/
----- technical base name: tenet.tetras-libre.fr_demo_01
----- source corpus: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-01/SSC-01-01.stog.amr.ttl
----- target reference: base
----- process level: sentence
----- source type: amr
-- Compositional Transduction Scheme (CTS)
----- CTS reference: amr_scheme_1
-- Directories
----- base directory: ./
----- structure directory: ./structure/
----- CTS directory: ./scheme/
----- target frame directory: ./../input/targetFrameStructure/
----- input document directory:
----- base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/SolarSystemDev01_factoid.ttl
----- output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/SolarSystemDev01_factoid.ttltenet.tetras-libre.fr_demo_01-20230404/
----- sentence output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/
----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/
-- Config File Definition
----- schema file: ./structure/amr-rdf-schema.ttl
----- semantic net file: ./structure/semantic-net.ttl
----- config param file: ./structure/config-parameters.ttl
----- base ontology file: ./structure/base-ontology.ttl
----- CTS file: ./scheme/amr_scheme_1.py
-- Useful References for Ontology
----- base URI: https://tenet.tetras-libre.fr/working
----- ontology suffix: -ontology.ttl
----- ontology seed suffix: -ontology-seed.ttl
-- Source File Definition
----- source sentence file: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-01/SSC-01-01.stog.amr.ttl**/*.ttl
-- Target File Definition
----- frame ontology file: ./../input/targetFrameStructure/base-ontology.ttl
----- frame ontology seed file: ./../input/targetFrameStructure/base-ontology-seed.ttl
-- Output
----- ontology namespace: https://tenet.tetras-libre.fr/base-ontology/
----- output file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01.ttl
*** - ***
- INFO -
=== Extraction Processing ===
- INFO - -- Work Structure Preparation
- DEBUG - --- Graph Initialization
- DEBUG - ----- Configuration Loading
- DEBUG - -------- RDF Schema (302)
- DEBUG - -------- Semantic Net Definition (513)
- DEBUG - -------- Config Parameter Definition (547)
- DEBUG - ----- Frame Ontology Loading
- DEBUG - -------- Base Ontology produced as output (577)
- DEBUG - --- Source Data Import
- DEBUG - ----- Sentence Loading
- DEBUG - -------- /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-01/SSC-01-01.stog.amr.ttl (625)
- DEBUG - --- Export work graph as turtle
- DEBUG - ----- Work graph file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01-0/tenet.tetras-libre.fr_demo_01.ttl
- INFO - ----- Sentence (id): SSC-01-01
- INFO - ----- Sentence (text): The Solar System is the gravitationally bound system of the Sun and the objects that orbit it, either directly or indirectly.
- INFO - -- Loading Extraction Scheme (amr_scheme_1)
- DEBUG - ----- Step number: 3
- INFO - -- Loading Extraction Rules (amr_rule/*)
- DEBUG - ----- Total rule number: 87
- INFO - -- Applying extraction step: preprocessing
- INFO - --- *** November Transduction *** Sequence: amrld-correcting-sequence
- INFO - ----- fix-amr-bug-about-system-solar-planet: 5/5 new triples (630, 0:00:00.026421)
- INFO - --- *** November Transduction *** Sequence: amr-reification-sequence
- INFO - ----- reclassify-concept-1: 10/10 new triples (640, 0:00:00.114925)
- DEBUG - ----- reclassify-concept-2: 0/0 new triple (640, 0:00:00.067262)
- INFO - ----- reclassify-concept-3: 12/12 new triples (652, 0:00:00.048916)
- INFO - ----- reclassify-concept-4: 16/16 new triples (668, 0:00:00.061935)
- INFO - ----- reclassify-concept-5: 2/4 new triples (670, 0:00:00.065744)
- INFO - ----- reify-roles-as-concept: 10/10 new triples (680, 0:00:00.069138)
- INFO - ----- reclassify-existing-variable: 45/45 new triples (725, 0:00:00.049915)
- INFO - ----- add-new-variable-for-reified-concept: 8/8 new triples (733, 0:00:00.079857)
- INFO - ----- add-amr-leaf-for-reclassified-concept: 33/33 new triples (766, 0:00:00.062893)
- INFO - ----- add-amr-leaf-for-reified-concept: 8/8 new triples (774, 0:00:00.045088)
- INFO - ----- add-amr-edge-for-core-relation: 27/27 new triples (801, 0:00:00.164098)
- INFO - ----- add-amr-edge-for-reified-concept: 12/12 new triples (813, 0:00:00.147240)
- INFO - ----- add-amr-edge-for-name-relation: 5/5 new triples (818, 0:00:00.072179)
- DEBUG - ----- add-value-for-quant-relation: 0/0 new triple (818, 0:00:00.165758)
- INFO - ----- add-amr-edge-for-polarity-relation: 5/5 new triples (823, 0:00:00.073797)
- INFO - ----- update-amr-edge-role-1: 15/15 new triples (838, 0:00:00.092753)
- INFO - ----- add-amr-root: 5/5 new triples (843, 0:00:00.034398)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_01_preprocessing
- DEBUG - ----- step: preprocessing
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/01/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01-0/tenet.tetras-libre.fr_demo_01_preprocessing.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/01//preprocessing
- INFO - ----- 218 triples extracted during preprocessing step
- INFO - -- Applying extraction step: transduction
- INFO - --- *** February Transduction *** Sequence: atomic-extraction-sequence
- INFO - ----- extract atom classes: 30/30 new triples (873, 0:00:00.161525)
- INFO - ----- extract atom individuals: 7/7 new triples (880, 0:00:00.045482)
- INFO - ----- extract atomic properties: 75/75 new triples (955, 0:00:00.213663)
- INFO - ----- extract atom values: 8/8 new triples (963, 0:00:00.045969)
- INFO - ----- extract atom phenomena: 14/14 new triples (977, 0:00:00.066710)
- INFO - ----- propagate atom relations: 19/56 new triples (996, 0:00:00.559967)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_01_transduction
- DEBUG - ----- step: transduction
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/01/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01-0/tenet.tetras-libre.fr_demo_01_transduction.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/01//transduction
- INFO - ----- 153 triples extracted during transduction step
- INFO - -- Applying extraction step: generation
- INFO - --- *** November Transduction *** Sequence: main-generation-sequence
- INFO - ----- compute-uri-for-owl-declaration-1: 5/5 new triples (1001, 0:00:00.023486)
- DEBUG - ----- compute-uri-for-owl-declaration-2: 0/0 new triple (1001, 0:00:00.018719)
- INFO - ----- compute-uri-for-owl-declaration-3: 1/1 new triple (1002, 0:00:00.037601)
- DEBUG - ----- compute-uri-for-owl-declaration-4: 0/0 new triple (1002, 0:00:00.021797)
- INFO - ----- compute-uri-for-owl-declaration-5: 6/6 new triples (1008, 0:00:00.022662)
- INFO - ----- compute-uri-for-owl-declaration-6: 6/6 new triples (1014, 0:00:00.033197)
- DEBUG - ----- compute-uri-for-owl-declaration-7: 0/0 new triple (1014, 0:00:00.020214)
- INFO - ----- generate-atom-class: 12/12 new triples (1026, 0:00:00.010894)
- DEBUG - ----- classify-atom-class-1: 0/0 new triple (1026, 0:00:00.010684)
- INFO - ----- classify-atom-class-2: 4/4 new triples (1030, 0:00:00.013890)
- INFO - ----- generate-individual: 3/3 new triples (1033, 0:00:00.008628)
- DEBUG - ----- classify-individual-1: 0/0 new triple (1033, 0:00:00.007893)
- INFO - ----- classify-individual-2: 1/1 new triple (1034, 0:00:00.009806)
- INFO - ----- generate-atom-property-1: 20/20 new triples (1054, 0:00:00.014649)
- INFO - ----- generate-atom-property-12: 20/20 new triples (1074, 0:00:00.014222)
- DEBUG - ----- generate-inverse-relation: 0/0 new triple (1074, 0:00:00.007821)
- DEBUG - ----- generate-composite-class: 0/0 new triple (1074, 0:00:00.008743)
- DEBUG - ----- add-restriction-to-class-1: 0/0 new triple (1074, 0:00:00.015881)
- DEBUG - ----- add-restriction-to-class-2: 0/0 new triple (1074, 0:00:00.029840)
- DEBUG - ----- add-restriction-to-class-3: 0/0 new triple (1074, 0:00:00.060334)
- DEBUG - ----- add-restriction-to-class-4: 0/0 new triple (1074, 0:00:00.021008)
- DEBUG - ----- add-restriction-to-class-5: 0/0 new triple (1074, 0:00:00.018702)
- DEBUG - ----- add-restriction-to-class-6: 0/0 new triple (1074, 0:00:00.015892)
- INFO - --- *** February Transduction *** Sequence: property_generation_sequence
- DEBUG - ----- generate OWL property: 0/24 new triple (1074, 0:00:00.154135)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_01_generation
- DEBUG - ----- step: generation
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/01/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01-0/tenet.tetras-libre.fr_demo_01_generation.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/01//generation
- INFO - ----- 78 triples extracted during generation step
- DEBUG - --- Serializing graph to factoid file (/home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/technical-data/tenet.tetras-libre.fr_demo_01-0/tenet.tetras-libre.fr_demo_01_factoid.ttl)
- DEBUG - ----- Number of factoids: 102
- DEBUG - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/01//factoid
- INFO -
=== Final Ontology Generation ===
- INFO - -- Making complete factoid graph by merging the result factoids
- INFO - ----- Total factoid number: 102
- INFO - -- Serializing graph to factoid string
- INFO - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/01//factoid
- INFO - -- Serializing graph to factoid file
- INFO - ----- Ontology Turtle File: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev01-20230404/SolarSystemDev01_factoid.ttl
- INFO -
=== Done ===
- INFO -
*** Execution Time ***
----- Function: create_ontology_from_amrld_file (tenet.main)
----- Total Time: 0:00:03.591400
----- Process Time: 0:00:03.536007
*** - ***
......@@ -381,7 +381,7 @@ class Net:
# -- Net Declaration
def __generate_net_declaration_triple(self):
def generate_net_declaration_triple(self):
triple_list = []
......@@ -421,7 +421,7 @@ class Net:
return attr_triple_list
def __generate_net_attribute_triples(self):
def generate_net_attribute_triples(self):
triple_list = []
......@@ -434,7 +434,7 @@ class Net:
# -- Net Relation(s)
def __generate_net_relation_triples(self):
def generate_net_relation_triples(self):
triple_list = []
......@@ -455,9 +455,9 @@ class Net:
triple_list = []
if self.uri is not None:
triple_list += self.__generate_net_declaration_triple()
triple_list += self.__generate_net_attribute_triples()
triple_list += self.__generate_net_relation_triples()
triple_list += self.generate_net_declaration_triple()
triple_list += self.generate_net_attribute_triples()
triple_list += self.generate_net_relation_triples()
return triple_list
......
......@@ -466,6 +466,7 @@ net:atomProperty_bind_b a net:Atom_Property_Net ;
:leaf_system_s .
net:atomProperty_hasManner_m9 a net:Atom_Property_Net ;
:role_ARG0 net:atomProperty_orbit_o2 ;
:role_ARG1 net:phenomena_conjunction-OR_o3 ;
net:coverBaseNode :leaf_hasManner_m9 ;
net:coverNode :leaf_hasManner_m9 ;
......@@ -496,22 +497,6 @@ net:atomProperty_hasPart_p9 a net:Atom_Property_Net ;
net:targetArgumentNode :leaf_and_a,
:leaf_system_s .
net:atomProperty_orbit_o2 a net:Atom_Property_Net ;
:role_ARG0 net:atomClass_object_o ;
:role_ARG1 net:atomClass_sun_s2 ;
net:coverBaseNode :leaf_orbit-01_o2 ;
net:coverNode :leaf_orbit-01_o2 ;
net:hasNaming "orbit" ;
net:hasPropertyName "orbit" ;
net:hasPropertyName01 "orbiting" ;
net:hasPropertyName10 "orbit-by" ;
net:hasPropertyName12 "orbit-of" ;
net:hasPropertyType owl:ObjectProperty ;
net:hasStructure "SSC-01-01" ;
net:isCoreRoleLinked "true" ;
net:targetArgumentNode :leaf_object_o,
:leaf_sun_s2 .
net:atomType a owl:AnnotationProperty ;
rdfs:label "atom type" ;
rdfs:subPropertyOf net:objectType .
......@@ -865,13 +850,6 @@ net:atomClass_gravitation_g a net:Atom_Class_Net ;
net:hasNaming "gravitation" ;
net:hasStructure "SSC-01-01" .
net:atomClass_system_p a net:Atom_Class_Net ;
net:coverBaseNode :leaf_system_p ;
net:coverNode :leaf_system_p ;
net:hasClassName "system" ;
net:hasNaming "system" ;
net:hasStructure "SSC-01-01" .
net:atomProperty_direct_d a net:Atom_Property_Net ;
net:coverBaseNode :leaf_direct-02_d ;
net:coverNode :leaf_direct-02_d ;
......@@ -897,6 +875,22 @@ net:atomProperty_direct_d2 a net:Atom_Property_Net ;
net:isCoreRoleLinked "true" ;
net:targetArgumentNode :value_negative .
net:atomProperty_orbit_o2 a net:Atom_Property_Net ;
:role_ARG0 net:atomClass_object_o ;
:role_ARG1 net:atomClass_sun_s2 ;
net:coverBaseNode :leaf_orbit-01_o2 ;
net:coverNode :leaf_orbit-01_o2 ;
net:hasNaming "orbit" ;
net:hasPropertyName "orbit" ;
net:hasPropertyName01 "orbiting" ;
net:hasPropertyName10 "orbit-by" ;
net:hasPropertyName12 "orbit-of" ;
net:hasPropertyType owl:ObjectProperty ;
net:hasStructure "SSC-01-01" ;
net:isCoreRoleLinked "true" ;
net:targetArgumentNode :leaf_object_o,
:leaf_sun_s2 .
net:class_list a owl:Class ;
rdfs:label "classList" ;
rdfs:subClassOf net:Type .
......@@ -1101,8 +1095,16 @@ net:atomClass_sun_s2 a net:Atom_Class_Net ;
net:hasNaming "sun" ;
net:hasStructure "SSC-01-01" .
net:atomClass_system_p a net:Atom_Class_Net ;
net:coverBaseNode :leaf_system_p ;
net:coverNode :leaf_system_p ;
net:hasClassName "system" ;
net:hasNaming "system" ;
net:hasStructure "SSC-01-01" .
net:atomClass_system_s a net:Atom_Class_Net ;
:role_domain net:individual_SolarSystem_p ;
:role_domain net:atomClass_system_p,
net:individual_SolarSystem_p ;
net:coverBaseNode :leaf_system_s ;
net:coverNode :leaf_system_s ;
net:hasClassName "system" ;
......
......@@ -30,6 +30,7 @@ from tenet.scheme.amr_rule.transduction import atom_individual_extractor as rule
from tenet.scheme.amr_rule.transduction import atom_property_extractor as rule_3
from tenet.scheme.amr_rule.transduction import atom_value_extractor as rule_4
from tenet.scheme.amr_rule.transduction import atom_phenomena_extractor as rule_5
from tenet.scheme.amr_rule.transduction import atom_relation_propagator as rule_6
from tenet.scheme import amr_rule
......@@ -63,10 +64,13 @@ def add_triples_in_graph(graph, triple_list):
print(f" ----- Added triples:")
n = 0
graph_length = len(graph)
for triple in triple_list:
graph.add(triple)
if graph_length < len(graph):
n += 1
graph_length = len(graph)
print_triple(triple, num=n)
graph.add(triple)
print(f" ----- Graph length after update: {len(graph)}")
......@@ -157,7 +161,9 @@ def test_rule_application(graph, rule):
rule_label, new_triple_list = rule(graph)
print(f' ----- label: {rule_label}')
print(f' ----- new_triple_list ({len(new_triple_list)}):')
print(f' ----- new_triple_list length: ({len(new_triple_list)})')
# for triple in new_triple_list:
# print_triple(triple)
add_triples_in_graph(graph, new_triple_list)
......@@ -235,4 +241,10 @@ if __name__ == '__main__':
test_rule_application(graph, rule_5.extract_atom_phenomena)
print('\n \n')
print('\n ///////////////////// Additional Tests')
print('\n *** Unit Test ***')
# test_rule_application(graph, rule_1.extract_atom_class)
# test_rule_application(graph, rule_3.extract_atom_property)
test_rule_application(graph, rule_6.propagate_atom_relation)
print('\n *** - ***')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment