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

New AMR Rule: transduction.phenomena_polarity_analyzer_2

parent 2355cef6
Branches
Tags
No related merge requests found
Showing
with 6767 additions and 175 deletions
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
# -*-coding:Utf-8 -* # -*-coding:Utf-8 -*
#============================================================================== #==============================================================================
# TENET: Rule to conjunctive phenomena or (rule 1) # TENET: Rule to negative polarity phenomena (rule 1)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Net Expansion AMR rule to analyse conjunctive phenomena (or) # Net Expansion AMR rule to analyse negative polarity phenomena
# Rule: property(class, or_phenomena) => compositeClass # Rule: polarity(property, 'negative') => compositeClass
#============================================================================== #==============================================================================
import rdflib import rdflib
...@@ -19,25 +19,19 @@ from transduction.naming_computer import define_composite_naming_2 ...@@ -19,25 +19,19 @@ from transduction.naming_computer import define_composite_naming_2
#============================================================================== #==============================================================================
# Select Pattern: polarity(property, 'negative') # Pattern Search: polarity(property, 'negative')
#============================================================================== #==============================================================================
POLARITY_RELATION = 'amr:role_polarity' POLARITY_RELATION = 'amr:role_polarity'
def __rule_pattern_query_code(graph): def __search_pattern(graph):
select_data_list = ['?property_net'] select_data_list = ['?property_net']
clause_list = [] clause_list = [f'?property_net a [rdfs:subClassOf* net:Property_Net].',
clause_list.append(f'?property_net a [rdfs:subClassOf* net:Property_Net].') f'?property_net {POLARITY_RELATION} ?value_net.',
clause_list.append(f'?property_net {POLARITY_RELATION} ?value_net.') ('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative'))]
clause_list.append(('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative')))
query_code = generate_select_query(graph, select_data_list, clause_list) query_code = generate_select_query(graph, select_data_list, clause_list)
return query_code result_set = graph.query(query_code)
return query_code, result_set
def __search_pattern(graph):
query_code = __rule_pattern_query_code(graph)
rule_pattern_set = graph.query(query_code)
return rule_pattern_set
...@@ -105,12 +99,12 @@ def __construct_negative_property_net(graph, property_net_1): ...@@ -105,12 +99,12 @@ def __construct_negative_property_net(graph, property_net_1):
# restriction_net, triple_list_1 = __construct_restriction_net(graph, property_net_1) # restriction_net, triple_list_1 = __construct_restriction_net(graph, property_net_1)
# composite_class_net.restriction = restriction_net.uri # composite_class_net.restriction = restriction_net.uri
# -- Relation Propagation
__propagate_relation(composite_property_net, property_net_1)
# -- Net Naming # -- Net Naming
composite_property_net.naming = define_composite_naming_2('not', property_net_1) composite_property_net.naming = define_composite_naming_2('not', property_net_1)
# -- Relation Propagation
__propagate_relation(composite_property_net, property_net_1)
# -- Finalization # -- Finalization
composite_property_net.finalize() composite_property_net.finalize()
triple_list_2 = composite_property_net.generate_triple_definition() triple_list_2 = composite_property_net.generate_triple_definition()
...@@ -121,23 +115,23 @@ def __construct_negative_property_net(graph, property_net_1): ...@@ -121,23 +115,23 @@ def __construct_negative_property_net(graph, property_net_1):
#============================================================================== #==============================================================================
# Main Method: analyze_phenomena_or_1 # Main Method
#============================================================================== #==============================================================================
def analyze_phenomena_polarity_1(graph): def analyze_phenomena_polarity_1(graph):
# -- Rule Initialization # -- Rule Initialization
rule_label = 'analyze "polarity" phenomena' rule_label = 'analyze "polarity" phenomena (1)'
rule_triple_list = []
# -- Search for patterns # -- Search for patterns
rule_pattern_set = __search_pattern(graph) _, pattern_set = __search_pattern(graph)
# -- Selection Analyzing (1) # -- Pattern Analysis
rule_triple_list = [] for pattern in pattern_set:
for selection_1 in rule_pattern_set:
# -- Net Selection # -- Net Selection
property_net = net.PropertyNet(graph, uri=selection_1.property_net) property_net = net.PropertyNet(graph, uri=pattern.property_net)
# -- New Negative Property Net # -- New Negative Property Net
negative_property_net, triple_list_1 = __construct_negative_property_net(graph, property_net) negative_property_net, triple_list_1 = __construct_negative_property_net(graph, property_net)
......
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Rule to negative polarity phenomena (rule 2)
#------------------------------------------------------------------------------
# Net Expansion AMR rule to analyse negative polarity phenomena
# Rule: polarity(phenomena, 'negative') => phenomena
#==============================================================================
import rdflib
from rdflib import Graph
import transduction
from transduction import net
from transduction.query_builder import generate_select_query
from transduction.naming_computer import define_axiom_naming
from transduction.naming_computer import define_composite_naming_2
#==============================================================================
# Pattern Search: polarity(phenomena, 'negative')
#==============================================================================
POLARITY_RELATION = 'amr:role_polarity'
PHENOMENA_TYPE_RELATION = 'net:hasPhenomenaType'
POSSIBLE_PHENOMENA_URI = 'amr:phenomena_modality_possible'
def __search_pattern(graph):
select_data_list = ['?phenomena_net', '?value_net']
clause_list = [f'?phenomena_net a [rdfs:subClassOf* net:Phenomena_Net].',
f'FILTER NOT EXISTS {{ ?phenomena_net a net:Deprecated_Net. }}',
f'?phenomena_net {PHENOMENA_TYPE_RELATION} {POSSIBLE_PHENOMENA_URI}.',
f'?phenomena_net {POLARITY_RELATION} ?value_net.',
('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative'))]
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 __filter_relation(relation_list):
result_list = []
for relation in relation_list:
check = True
(s, p, o) = relation
if s == o: check = False
if p == POLARITY_RELATION: check = False
if check: result_list.append(relation)
return result_list
def __propagate_relation(target_net, base_net):
target_net.input_relation_list = base_net.input_relation_list
out_relation_list = __filter_relation(base_net.output_relation_list)
target_net.output_relation_list = out_relation_list
#==============================================================================
# Construct Method(s)
#==============================================================================
def __construct_phenomena_net(graph, origin_phenomena_net, value_net):
# -- Net Composition
new_phenomena_net = net.PhenomenaNet(graph)
new_phenomena_net.compose(origin_phenomena_net, value_net)
# -- Data Computation
new_phenomena_net.phenomena_type = 'amr:phenomena_modality_prohibition'
new_phenomena_net.phenomena_ref = f'not-{origin_phenomena_net.phenomena_ref}'
# -- Net Naming
new_phenomena_net.naming = 'prohibition-modality'
# -- Relation Propagation
__propagate_relation(new_phenomena_net, origin_phenomena_net)
# -- Finalization
new_phenomena_net.finalize()
triple_definition = new_phenomena_net.generate_triple_definition()
return new_phenomena_net, triple_definition
#==============================================================================
# Main Method
#==============================================================================
def analyze_phenomena_polarity_2(graph):
# -- Rule Initialization
rule_label = 'analyze "polarity" phenomena (2)'
rule_triple_list = []
# -- Search for patterns
_, pattern_set = __search_pattern(graph)
# -- Pattern Analysis
for pattern in pattern_set:
origin_phenomena_net = net.PhenomenaNet(graph, uri=pattern.phenomena_net)
value_net = net.ValueNet(graph, uri=pattern.value_net)
# -- New Negative Property Net
_, triple_list_1 = __construct_phenomena_net(graph, origin_phenomena_net, value_net)
rule_triple_list += triple_list_1
# -- Deprecation: Origin Class Net
rule_triple_list += origin_phenomena_net.deprecate()
return rule_label, rule_triple_list
\ No newline at end of file
...@@ -12,6 +12,7 @@ from scheme.amr_master_rule.transduction.composite_class_extractor_1 import * ...@@ -12,6 +12,7 @@ from scheme.amr_master_rule.transduction.composite_class_extractor_1 import *
from scheme.amr_master_rule.transduction.composite_class_extractor_2 import * from scheme.amr_master_rule.transduction.composite_class_extractor_2 import *
from scheme.amr_master_rule.transduction.phenomena_polarity_analyzer_1 import * from scheme.amr_master_rule.transduction.phenomena_polarity_analyzer_1 import *
from scheme.amr_master_rule.transduction.phenomena_polarity_analyzer_2 import *
from scheme.amr_master_rule.transduction.phenomena_mod_analyzer_1 import * from scheme.amr_master_rule.transduction.phenomena_mod_analyzer_1 import *
from scheme.amr_master_rule.transduction.phenomena_or_analyzer_1 import * from scheme.amr_master_rule.transduction.phenomena_or_analyzer_1 import *
from scheme.amr_master_rule.transduction.phenomena_or_analyzer_2 import * from scheme.amr_master_rule.transduction.phenomena_or_analyzer_2 import *
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
# -*-coding:Utf-8 -* # -*-coding:Utf-8 -*
#============================================================================== #==============================================================================
# TENET: Rule to conjunctive phenomena or (rule 1) # TENET: Rule to negative polarity phenomena (rule 1)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Net Expansion AMR rule to analyse conjunctive phenomena (or) # Net Expansion AMR rule to analyse negative polarity phenomena
# Rule: property(class, or_phenomena) => compositeClass # Rule: polarity(property, 'negative') => compositeClass
#============================================================================== #==============================================================================
import rdflib import rdflib
...@@ -19,25 +19,19 @@ from transduction.naming_computer import define_composite_naming_2 ...@@ -19,25 +19,19 @@ from transduction.naming_computer import define_composite_naming_2
#============================================================================== #==============================================================================
# Select Pattern: polarity(property, 'negative') # Pattern Search: polarity(property, 'negative')
#============================================================================== #==============================================================================
POLARITY_RELATION = 'amr:role_polarity' POLARITY_RELATION = 'amr:role_polarity'
def __rule_pattern_query_code(graph): def __search_pattern(graph):
select_data_list = ['?property_net'] select_data_list = ['?property_net']
clause_list = [] clause_list = [f'?property_net a [rdfs:subClassOf* net:Property_Net].',
clause_list.append(f'?property_net a [rdfs:subClassOf* net:Property_Net].') f'?property_net {POLARITY_RELATION} ?value_net.',
clause_list.append(f'?property_net {POLARITY_RELATION} ?value_net.') ('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative'))]
clause_list.append(('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative')))
query_code = generate_select_query(graph, select_data_list, clause_list) query_code = generate_select_query(graph, select_data_list, clause_list)
return query_code result_set = graph.query(query_code)
return query_code, result_set
def __search_pattern(graph):
query_code = __rule_pattern_query_code(graph)
rule_pattern_set = graph.query(query_code)
return rule_pattern_set
...@@ -105,12 +99,12 @@ def __construct_negative_property_net(graph, property_net_1): ...@@ -105,12 +99,12 @@ def __construct_negative_property_net(graph, property_net_1):
# restriction_net, triple_list_1 = __construct_restriction_net(graph, property_net_1) # restriction_net, triple_list_1 = __construct_restriction_net(graph, property_net_1)
# composite_class_net.restriction = restriction_net.uri # composite_class_net.restriction = restriction_net.uri
# -- Relation Propagation
__propagate_relation(composite_property_net, property_net_1)
# -- Net Naming # -- Net Naming
composite_property_net.naming = define_composite_naming_2('not', property_net_1) composite_property_net.naming = define_composite_naming_2('not', property_net_1)
# -- Relation Propagation
__propagate_relation(composite_property_net, property_net_1)
# -- Finalization # -- Finalization
composite_property_net.finalize() composite_property_net.finalize()
triple_list_2 = composite_property_net.generate_triple_definition() triple_list_2 = composite_property_net.generate_triple_definition()
...@@ -121,23 +115,23 @@ def __construct_negative_property_net(graph, property_net_1): ...@@ -121,23 +115,23 @@ def __construct_negative_property_net(graph, property_net_1):
#============================================================================== #==============================================================================
# Main Method: analyze_phenomena_or_1 # Main Method
#============================================================================== #==============================================================================
def analyze_phenomena_polarity_1(graph): def analyze_phenomena_polarity_1(graph):
# -- Rule Initialization # -- Rule Initialization
rule_label = 'analyze "polarity" phenomena' rule_label = 'analyze "polarity" phenomena (1)'
rule_triple_list = []
# -- Search for patterns # -- Search for patterns
rule_pattern_set = __search_pattern(graph) _, pattern_set = __search_pattern(graph)
# -- Selection Analyzing (1) # -- Pattern Analysis
rule_triple_list = [] for pattern in pattern_set:
for selection_1 in rule_pattern_set:
# -- Net Selection # -- Net Selection
property_net = net.PropertyNet(graph, uri=selection_1.property_net) property_net = net.PropertyNet(graph, uri=pattern.property_net)
# -- New Negative Property Net # -- New Negative Property Net
negative_property_net, triple_list_1 = __construct_negative_property_net(graph, property_net) negative_property_net, triple_list_1 = __construct_negative_property_net(graph, property_net)
......
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Rule to negative polarity phenomena (rule 2)
#------------------------------------------------------------------------------
# Net Expansion AMR rule to analyse negative polarity phenomena
# Rule: polarity(phenomena, 'negative') => phenomena
#==============================================================================
import rdflib
from rdflib import Graph
import transduction
from transduction import net
from transduction.query_builder import generate_select_query
from transduction.naming_computer import define_axiom_naming
from transduction.naming_computer import define_composite_naming_2
#==============================================================================
# Pattern Search: polarity(phenomena, 'negative')
#==============================================================================
POLARITY_RELATION = 'amr:role_polarity'
PHENOMENA_TYPE_RELATION = 'net:hasPhenomenaType'
POSSIBLE_PHENOMENA_URI = 'amr:phenomena_modality_possible'
def __search_pattern(graph):
select_data_list = ['?phenomena_net', '?value_net']
clause_list = [f'?phenomena_net a [rdfs:subClassOf* net:Phenomena_Net].',
f'FILTER NOT EXISTS {{ ?phenomena_net a net:Deprecated_Net. }}',
f'?phenomena_net {PHENOMENA_TYPE_RELATION} {POSSIBLE_PHENOMENA_URI}.',
f'?phenomena_net {POLARITY_RELATION} ?value_net.',
('?value_net', 'net:hasValueLabel', rdflib.term.Literal('negative'))]
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 __filter_relation(relation_list):
result_list = []
for relation in relation_list:
check = True
(s, p, o) = relation
if s == o: check = False
if p == POLARITY_RELATION: check = False
if check: result_list.append(relation)
return result_list
def __propagate_relation(target_net, base_net):
target_net.input_relation_list = base_net.input_relation_list
out_relation_list = __filter_relation(base_net.output_relation_list)
target_net.output_relation_list = out_relation_list
#==============================================================================
# Construct Method(s)
#==============================================================================
def __construct_phenomena_net(graph, origin_phenomena_net, value_net):
# -- Net Composition
new_phenomena_net = net.PhenomenaNet(graph)
new_phenomena_net.compose(origin_phenomena_net, value_net)
# -- Data Computation
new_phenomena_net.phenomena_type = 'amr:phenomena_modality_prohibition'
new_phenomena_net.phenomena_ref = f'not-{origin_phenomena_net.phenomena_ref}'
# -- Net Naming
new_phenomena_net.naming = 'prohibition-modality'
# -- Relation Propagation
__propagate_relation(new_phenomena_net, origin_phenomena_net)
# -- Finalization
new_phenomena_net.finalize()
triple_definition = new_phenomena_net.generate_triple_definition()
return new_phenomena_net, triple_definition
#==============================================================================
# Main Method
#==============================================================================
def analyze_phenomena_polarity_2(graph):
# -- Rule Initialization
rule_label = 'analyze "polarity" phenomena (2)'
rule_triple_list = []
# -- Search for patterns
_, pattern_set = __search_pattern(graph)
# -- Pattern Analysis
for pattern in pattern_set:
origin_phenomena_net = net.PhenomenaNet(graph, uri=pattern.phenomena_net)
value_net = net.ValueNet(graph, uri=pattern.value_net)
# -- New Negative Property Net
_, triple_list_1 = __construct_phenomena_net(graph, origin_phenomena_net, value_net)
rule_triple_list += triple_list_1
# -- Deprecation: Origin Class Net
rule_triple_list += origin_phenomena_net.deprecate()
return rule_label, rule_triple_list
\ No newline at end of file
...@@ -180,6 +180,7 @@ atomic_extraction_sequence = ['atomic extraction sequence', ...@@ -180,6 +180,7 @@ atomic_extraction_sequence = ['atomic extraction sequence',
phenomena_analyze_sequence_1 = ['phenomena analyze sequence (1)', phenomena_analyze_sequence_1 = ['phenomena analyze sequence (1)',
rule.analyze_phenomena_polarity_1, rule.analyze_phenomena_polarity_1,
rule.analyze_phenomena_polarity_2,
rule.analyze_phenomena_mod_1 rule.analyze_phenomena_mod_1
] ]
......
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
- INFO - - INFO -
=== Process Initialization === === Process Initialization ===
- INFO - -- Process Setting - INFO - -- Process Setting
- INFO - ----- Corpus source: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/asail_odrl_sentences/s01.stog.amr.ttl (amr) - INFO - ----- Corpus source: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-02/SSC-02-01.stog.amr.ttl (amr)
- INFO - ----- Base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/aos01_factoid.ttl - INFO - ----- Base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/SolarSystemDev02_factoid.ttl
- INFO - ----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/ - INFO - ----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/
- INFO - ----- Ontology target (id): https://tenet.tetras-libre.fr/demo/clara/01/ - INFO - ----- Ontology target (id): https://tenet.tetras-libre.fr/demo/02/
- INFO - ----- Current path: /home/lamenji/Workspace/Tetras/tenet/tenet - INFO - ----- Current path: /home/lamenji/Workspace/Tetras/tenet/tenet
- DEBUG - ----- Config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml - DEBUG - ----- Config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml
- DEBUG - - DEBUG -
*** Config (Full Parameters) *** *** Config (Full Parameters) ***
-- Base Parameters -- Base Parameters
----- config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml ----- config file: /home/lamenji/Workspace/Tetras/tenet/tenet/config.xml
----- uuid: https://tenet.tetras-libre.fr/demo/clara/01/ ----- uuid: https://tenet.tetras-libre.fr/demo/02/
----- technical base name: tenet.tetras-libre.fr_demo_clara_01 ----- technical base name: tenet.tetras-libre.fr_demo_02
----- source corpus: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/asail_odrl_sentences/s01.stog.amr.ttl ----- source corpus: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-02/SSC-02-01.stog.amr.ttl
----- target reference: base ----- target reference: base
----- process level: sentence ----- process level: sentence
----- source type: amr ----- source type: amr
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
----- CTS directory: ./scheme/ ----- CTS directory: ./scheme/
----- target frame directory: ./../input/targetFrameStructure/ ----- target frame directory: ./../input/targetFrameStructure/
----- input document directory: ----- input document directory:
----- base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/aos01_factoid.ttl ----- base output dir: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/SolarSystemDev02_factoid.ttl
----- output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/aos01_factoid.ttltenet.tetras-libre.fr_demo_clara_01-20230412/ ----- output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/SolarSystemDev02_factoid.ttltenet.tetras-libre.fr_demo_02-20230413/
----- sentence output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/ ----- sentence output directory: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/
----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/ ----- technical dir path: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/
-- Config File Definition -- Config File Definition
----- schema file: ./structure/amr-rdf-schema.ttl ----- schema file: ./structure/amr-rdf-schema.ttl
----- semantic net file: ./structure/odrl-snet-schema.ttl ----- semantic net file: ./structure/odrl-snet-schema.ttl
...@@ -41,112 +41,113 @@ ...@@ -41,112 +41,113 @@
----- ontology suffix: -ontology.ttl ----- ontology suffix: -ontology.ttl
----- ontology seed suffix: -ontology-seed.ttl ----- ontology seed suffix: -ontology-seed.ttl
-- Source File Definition -- Source File Definition
----- source sentence file: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/asail_odrl_sentences/s01.stog.amr.ttl**/*.ttl ----- source sentence file: /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-02/SSC-02-01.stog.amr.ttl**/*.ttl
-- Target File Definition -- Target File Definition
----- frame ontology file: ./../input/targetFrameStructure/base-ontology.ttl ----- frame ontology file: ./../input/targetFrameStructure/base-ontology.ttl
----- frame ontology seed file: ./../input/targetFrameStructure/base-ontology-seed.ttl ----- frame ontology seed file: ./../input/targetFrameStructure/base-ontology-seed.ttl
-- Output -- Output
----- ontology namespace: https://tenet.tetras-libre.fr/base-ontology/ ----- ontology namespace: https://tenet.tetras-libre.fr/base-ontology/
----- output file: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01.ttl ----- output file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02.ttl
*** - *** *** - ***
- INFO - - INFO -
=== Extraction Processing === === Extraction Processing ===
- INFO - -- Work Structure Preparation - INFO - -- Work Structure Preparation
- DEBUG - --- Graph Initialization - DEBUG - --- Graph Initialization
- DEBUG - ----- Configuration Loading - DEBUG - ----- Configuration Loading
- DEBUG - -------- RDF Schema (316) - DEBUG - -------- RDF Schema (319)
- DEBUG - -------- Semantic Net Definition (462) - DEBUG - -------- Semantic Net Definition (465)
- DEBUG - -------- Config Parameter Definition (496) - DEBUG - -------- Config Parameter Definition (499)
- DEBUG - ----- Frame Ontology Loading - DEBUG - ----- Frame Ontology Loading
- DEBUG - -------- Base Ontology produced as output (526) - DEBUG - -------- Base Ontology produced as output (529)
- DEBUG - --- Source Data Import - DEBUG - --- Source Data Import
- DEBUG - ----- Sentence Loading - DEBUG - ----- Sentence Loading
- DEBUG - -------- /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/asail_odrl_sentences/s01.stog.amr.ttl (543) - DEBUG - -------- /home/lamenji/Workspace/Tetras/tenet/tests/input/amrDocuments/dev/solar-system-02/SSC-02-01.stog.amr.ttl (604)
- DEBUG - --- Export work graph as turtle - DEBUG - --- Export work graph as turtle
- DEBUG - ----- Work graph file: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01-0/tenet.tetras-libre.fr_demo_clara_01.ttl - DEBUG - ----- Work graph file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02-0/tenet.tetras-libre.fr_demo_02.ttl
- INFO - ----- Sentence (id): document-01 - INFO - ----- Sentence (id): SSC-02-01
- INFO - ----- Sentence (text): Movie9898 can be used. - INFO - ----- Sentence (text): Of the objects that orbit the Sun directly, the largest are the eight planets, with the remainder being smaller objects, the dwarf planets and small Solar System bodies.
- INFO - -- Loading Extraction Scheme (amr_scheme_clara_1) - INFO - -- Loading Extraction Scheme (amr_scheme_clara_1)
- DEBUG - ----- Step number: 3 - DEBUG - ----- Step number: 3
- INFO - -- Loading Extraction Rules (amr_clara_rule/*) - INFO - -- Loading Extraction Rules (amr_clara_rule/*)
- DEBUG - ----- Total rule number: 87 - DEBUG - ----- Total rule number: 87
- INFO - -- Applying extraction step: preprocessing - INFO - -- Applying extraction step: preprocessing
- INFO - --- *** November Transduction *** Sequence: amrld-correcting-sequence - INFO - --- *** November Transduction *** Sequence: amrld-correcting-sequence
- DEBUG - ----- fix-amr-bug-about-system-solar-planet: 0/0 new triple (543, 0:00:00.028270) - DEBUG - ----- fix-amr-bug-about-system-solar-planet: 0/0 new triple (604, 0:00:00.034381)
- INFO - --- *** November Transduction *** Sequence: amr-reification-sequence - INFO - --- *** November Transduction *** Sequence: amr-reification-sequence
- INFO - ----- reclassify-concept-1: 5/5 new triples (548, 0:00:00.104339) - INFO - ----- reclassify-concept-1: 10/10 new triples (614, 0:00:00.194762)
- DEBUG - ----- reclassify-concept-2: 0/0 new triple (548, 0:00:00.158565) - INFO - ----- reclassify-concept-2: 8/8 new triples (622, 0:00:00.068636)
- INFO - ----- reclassify-concept-3: 4/4 new triples (552, 0:00:00.045084) - INFO - ----- reclassify-concept-3: 12/12 new triples (634, 0:00:00.055525)
- INFO - ----- reclassify-concept-4: 4/4 new triples (556, 0:00:00.064150) - INFO - ----- reclassify-concept-4: 28/28 new triples (662, 0:00:00.129317)
- DEBUG - ----- reclassify-concept-5: 0/0 new triple (556, 0:00:00.053422) - INFO - ----- reclassify-concept-5: 4/4 new triples (666, 0:00:00.046888)
- DEBUG - ----- reify-roles-as-concept: 0/0 new triple (556, 0:00:00.044123) - INFO - ----- reify-roles-as-concept: 5/5 new triples (671, 0:00:00.060386)
- INFO - ----- reclassify-existing-variable: 13/13 new triples (569, 0:00:00.035977) - INFO - ----- reclassify-existing-variable: 81/81 new triples (752, 0:00:00.041207)
- DEBUG - ----- add-new-variable-for-reified-concept: 0/0 new triple (569, 0:00:00.055366) - INFO - ----- add-new-variable-for-reified-concept: 4/4 new triples (756, 0:00:00.060325)
- INFO - ----- add-amr-leaf-for-reclassified-concept: 9/9 new triples (578, 0:00:00.036535) - INFO - ----- add-amr-leaf-for-reclassified-concept: 60/60 new triples (816, 0:00:00.084328)
- DEBUG - ----- add-amr-leaf-for-reified-concept: 0/0 new triple (578, 0:00:00.030991) - INFO - ----- add-amr-leaf-for-reified-concept: 4/4 new triples (820, 0:00:00.034523)
- INFO - ----- add-amr-edge-for-core-relation: 6/6 new triples (584, 0:00:00.095660) - INFO - ----- add-amr-edge-for-core-relation: 54/54 new triples (874, 0:00:00.186985)
- DEBUG - ----- add-amr-edge-for-reified-concept: 0/0 new triple (584, 0:00:00.077738) - INFO - ----- add-amr-edge-for-reified-concept: 6/6 new triples (880, 0:00:00.226187)
- INFO - ----- add-amr-edge-for-name-relation: 5/5 new triples (589, 0:00:00.076647) - INFO - ----- add-amr-edge-for-name-relation: 5/5 new triples (885, 0:00:00.111143)
- DEBUG - ----- add-value-for-quant-relation: 0/0 new triple (589, 0:00:00.076118) - INFO - ----- add-value-for-quant-relation: 5/5 new triples (890, 0:00:00.116261)
- DEBUG - ----- add-amr-edge-for-polarity-relation: 0/0 new triple (589, 0:00:00.086418) - DEBUG - ----- add-amr-edge-for-polarity-relation: 0/0 new triple (890, 0:00:00.120961)
- INFO - ----- update-amr-edge-role-1: 3/3 new triples (592, 0:00:00.032250) - INFO - ----- update-amr-edge-role-1: 22/22 new triples (912, 0:00:00.162784)
- INFO - ----- add-amr-root: 5/5 new triples (597, 0:00:00.025676) - INFO - ----- add-amr-root: 5/5 new triples (917, 0:00:00.030564)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_clara_01_preprocessing - DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_02_preprocessing
- DEBUG - ----- step: preprocessing - DEBUG - ----- step: preprocessing
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/clara/01/ - DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/02/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01-0/tenet.tetras-libre.fr_demo_clara_01_preprocessing.ttl - DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02-0/tenet.tetras-libre.fr_demo_02_preprocessing.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/clara/01//preprocessing - DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/02//preprocessing
- INFO - ----- 54 triples extracted during preprocessing step - INFO - ----- 313 triples extracted during preprocessing step
- INFO - -- Applying extraction step: transduction - INFO - -- Applying extraction step: transduction
- INFO - --- *** February Transduction *** Sequence: atomic extraction sequence - INFO - --- *** February Transduction *** Sequence: atomic extraction sequence
- INFO - ----- extract atom classes: 6/6 new triples (603, 0:00:00.043952) - INFO - ----- extract atom classes: 66/66 new triples (983, 0:00:00.389988)
- INFO - ----- extract atom individuals: 7/7 new triples (610, 0:00:00.043940) - INFO - ----- extract atom individuals: 7/7 new triples (990, 0:00:00.055133)
- INFO - ----- extract atomic properties: 12/12 new triples (622, 0:00:00.051127) - INFO - ----- extract atomic properties: 72/72 new triples (1062, 0:00:00.240536)
- INFO - ----- extract atom values: 4/4 new triples (626, 0:00:00.027869) - INFO - ----- extract atom values: 10/10 new triples (1072, 0:00:00.052099)
- INFO - ----- extract atom phenomena: 7/7 new triples (633, 0:00:00.040272) - INFO - ----- extract atom phenomena: 28/28 new triples (1100, 0:00:00.126989)
- INFO - ----- propagate atom relations: 4/12 new triples (637, 0:00:00.165620) - INFO - ----- propagate atom relations: 35/90 new triples (1135, 0:00:01.757192)
- INFO - --- *** February Transduction *** Sequence: phenomena analyze sequence (1) - INFO - --- *** February Transduction *** Sequence: phenomena analyze sequence (1)
- DEBUG - ----- analyze "polarity" phenomena: 0/0 new triple (637, 0:00:00.009180) - DEBUG - ----- analyze "polarity" phenomena (1): 0/0 new triple (1135, 0:00:00.008545)
- DEBUG - ----- analyze modifier phenomena (mod): 0/0 new triple (637, 0:00:00.010339) - DEBUG - ----- analyze "polarity" phenomena (2): 0/0 new triple (1135, 0:00:00.014269)
- INFO - ----- analyze modifier phenomena (mod): 43/48 new triples (1178, 0:00:00.220329)
- INFO - --- *** February Transduction *** Sequence: phenomena analyze sequence (2) - INFO - --- *** February Transduction *** Sequence: phenomena analyze sequence (2)
- DEBUG - ----- analyze "or" phenomena (1): 0/0 new triple (637, 0:00:00.011306) - DEBUG - ----- analyze "or" phenomena (1): 0/0 new triple (1178, 0:00:00.011967)
- DEBUG - ----- analyze "or" phenomena (2): 0/0 new triple (637, 0:00:00.012883) - DEBUG - ----- analyze "or" phenomena (2): 0/0 new triple (1178, 0:00:00.019760)
- INFO - --- *** February Transduction *** Sequence: composite class extraction sequence - INFO - --- *** February Transduction *** Sequence: composite class extraction sequence
- DEBUG - ----- extract composite classes (1): 0/0 new triple (637, 0:00:00.024933) - INFO - ----- extract composite classes (1): 47/48 new triples (1225, 0:00:00.249988)
- DEBUG - ----- extract composite classes (2): 0/0 new triple (637, 0:00:00.020872) - DEBUG - ----- extract composite classes (2): 0/0 new triple (1225, 0:00:00.027102)
- INFO - --- *** February Transduction *** Sequence: ODRL extraction sequence - INFO - --- *** February Transduction *** Sequence: ODRL extraction sequence
- DEBUG - ----- extract ODRL rules: 0/0 new triple (637, 0:00:00.066762) - DEBUG - ----- extract ODRL rules: 0/0 new triple (1225, 0:00:00.072281)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_clara_01_transduction - DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_02_transduction
- DEBUG - ----- step: transduction - DEBUG - ----- step: transduction
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/clara/01/ - DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/02/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01-0/tenet.tetras-libre.fr_demo_clara_01_transduction.ttl - DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02-0/tenet.tetras-libre.fr_demo_02_transduction.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/clara/01//transduction - DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/02//transduction
- INFO - ----- 40 triples extracted during transduction step - INFO - ----- 308 triples extracted during transduction step
- INFO - -- Applying extraction step: generation - INFO - -- Applying extraction step: generation
- INFO - --- *** February Transduction *** Sequence: ODRL Rule Generation Sequence - INFO - --- *** February Transduction *** Sequence: ODRL Rule Generation Sequence
- DEBUG - ----- generate ODRL rule: 0/0 new triple (637, 0:00:00.008132) - DEBUG - ----- generate ODRL rule: 0/0 new triple (1225, 0:00:00.005623)
- DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_clara_01_generation - DEBUG - --- Serializing graph to tenet.tetras-libre.fr_demo_02_generation
- DEBUG - ----- step: generation - DEBUG - ----- step: generation
- DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/clara/01/ - DEBUG - ----- id: https://tenet.tetras-libre.fr/demo/02/
- DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01-0/tenet.tetras-libre.fr_demo_clara_01_generation.ttl - DEBUG - ----- work_file: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02-0/tenet.tetras-libre.fr_demo_02_generation.ttl
- DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/clara/01//generation - DEBUG - ----- base: http://https://tenet.tetras-libre.fr/demo/02//generation
- INFO - ----- 0 triples extracted during generation step - INFO - ----- 0 triples extracted during generation step
- DEBUG - --- Serializing graph to factoid file (/home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/technical-data/tenet.tetras-libre.fr_demo_clara_01-0/tenet.tetras-libre.fr_demo_clara_01_factoid.ttl) - DEBUG - --- Serializing graph to factoid file (/home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/technical-data/tenet.tetras-libre.fr_demo_02-0/tenet.tetras-libre.fr_demo_02_factoid.ttl)
- DEBUG - ----- Number of factoids: 0 - DEBUG - ----- Number of factoids: 0
- DEBUG - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/clara/01//factoid - DEBUG - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/02//factoid
- INFO - - INFO -
=== Final Ontology Generation === === Final Ontology Generation ===
- INFO - -- Making complete factoid graph by merging the result factoids - INFO - -- Making complete factoid graph by merging the result factoids
- INFO - ----- Total factoid number: 0 - INFO - ----- Total factoid number: 0
- INFO - -- Serializing graph to factoid string - INFO - -- Serializing graph to factoid string
- INFO - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/clara/01//factoid - INFO - ----- Graph base: http://https://tenet.tetras-libre.fr/demo/02//factoid
- INFO - -- Serializing graph to factoid file - INFO - -- Serializing graph to factoid file
- INFO - ----- Ontology Turtle File: /home/lamenji/Workspace/Tetras/tenet/tests/output/aos01-20230412/aos01_factoid.ttl - INFO - ----- Ontology Turtle File: /home/lamenji/Workspace/Tetras/tenet/tests/output/SolarSystemDev02-20230413/SolarSystemDev02_factoid.ttl
- INFO - - INFO -
=== Done === === Done ===
- INFO - - INFO -
*** Execution Time *** *** Execution Time ***
----- Function: create_ontology_from_amrld_file (tenet.main) ----- Function: create_ontology_from_amrld_file (tenet.main)
----- Total Time: 0:00:02.039175 ----- Total Time: 0:00:05.646801
----- Process Time: 0:00:01.996954 ----- Process Time: 0:00:05.470157
*** - *** *** - ***
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -15,14 +15,15 @@ from rdflib import URIRef, Literal, BNode ...@@ -15,14 +15,15 @@ from rdflib import URIRef, Literal, BNode
FILE_PATH = f'{os.path.dirname(os.path.abspath(__file__))}' FILE_PATH = f'{os.path.dirname(os.path.abspath(__file__))}'
INPUT_DIR_PATH = f'{FILE_PATH}/test_data/' INPUT_DIR_PATH = f'{FILE_PATH}/test_data/'
OUTPUT_DIR_PATH = f'{FILE_PATH}/test_data/' OUTPUT_DIR_PATH = f'{FILE_PATH}/test_data/'
TEST_NAME = 'devGraph-negation-1' # 'devGraph2'
INPUT_GRAPH_PATH = f'{INPUT_DIR_PATH}{TEST_NAME}.ttl' TEST_FILE_NAME_1 = 'negation-devGraph-1'
OUTPUT_GRAPH_PATH = f'{OUTPUT_DIR_PATH}phenomena-polarity.result.ttl' TEST_FILE_NAME_2 = 'negation-devGraph-2'
OUTPUT_GRAPH_URI = f'https://amr.tetras-libre.fr/rdf/devGraph1/result' TEST_FILE_NAME_3 = 'negation-devGraph-3'
from context import tenet from context import tenet
from tenet.scheme.amr_rule.transduction import phenomena_polarity_analyzer_1 as rule_1 from tenet.scheme.amr_master_rule.transduction import phenomena_polarity_analyzer_1 as rule_1
from tenet.scheme import amr_rule as rule from tenet.scheme.amr_clara_rule.transduction import phenomena_polarity_analyzer_2 as rule_2
from tenet.scheme import amr_master_rule as rule
from tenet.transduction import net from tenet.transduction import net
from tenet.transduction.rdfterm_computer import __update_uri_with_prefix from tenet.transduction.rdfterm_computer import __update_uri_with_prefix
...@@ -36,11 +37,12 @@ from transduction.naming_computer import define_composite_naming_2 ...@@ -36,11 +37,12 @@ from transduction.naming_computer import define_composite_naming_2
# Useful Methods # Useful Methods
#============================================================================== #==============================================================================
def load_test_graph(): def load_test_graph(test_file_name):
print(f'\n -- Test Graph Loading') print(f'\n -- Test Graph Loading')
graph = Graph() graph = Graph()
prefix_handle.update_graph_namespacemanager(graph) prefix_handle.update_graph_namespacemanager(graph)
graph.parse(INPUT_GRAPH_PATH) graph_path = f'{INPUT_DIR_PATH}{test_file_name}.ttl'
graph.parse(graph_path)
print(f" ----- Graph Loaded ({len(graph)})") print(f" ----- Graph Loaded ({len(graph)})")
return graph return graph
...@@ -52,13 +54,7 @@ def print_net_attributes(net): ...@@ -52,13 +54,7 @@ def print_net_attributes(net):
print(f' ----- {attr}: {eval(net_attr_ref)}') print(f' ----- {attr}: {eval(net_attr_ref)}')
def define_clause_list(composition_pattern_list): def print_triple(graph, triple, num=-1):
clause_list = []
for (net_1, relation, net_2) in composition_pattern_list:
clause_list.append(f'{net_1} {relation} {net_2}.')
return clause_list
def print_triple(triple, num=-1):
num_str = f'[{num}]' if num > -1 else '[-]' num_str = f'[{num}]' if num > -1 else '[-]'
(s, p, o) = triple (s, p, o) = triple
s = __update_uri_with_prefix(graph, s) s = __update_uri_with_prefix(graph, s)
...@@ -67,60 +63,68 @@ def print_triple(triple, num=-1): ...@@ -67,60 +63,68 @@ def print_triple(triple, num=-1):
print(f' {num_str} {s} {p} {o}') print(f' {num_str} {s} {p} {o}')
def add_triples_in_graph(test_file_name, graph, triple_list):
def add_triples_in_graph(graph, triple_list):
print(f'\n -- Adding triple(s) in graph') print(f'\n -- Adding triple(s) in graph')
print(f" ----- Graph length before update: {len(graph)}") print(f" ----- Graph length before update: {len(graph)}")
print(f" ----- Number of triples to add: {len(triple_list)}") print(f" ----- Number of triples to add: {len(triple_list)}")
print(f" ----- Added triples:") print(f" ----- Added triples:")
n = 0 n = 0
graph_length = len(graph)
for triple in triple_list: for triple in triple_list:
n += 1
print_triple(triple, num=n)
graph.add(triple) graph.add(triple)
if graph_length < len(graph):
n += 1
graph_length = len(graph)
print_triple(graph, triple, num=n)
print(f" ----- Graph length after update: {len(graph)}") print(f" ----- Graph length after update: {len(graph)}")
print(f'\n -- Serialize test graph to {OUTPUT_GRAPH_PATH}') output_graph_path = f'{OUTPUT_DIR_PATH}{test_file_name}.result.ttl'
graph.serialize(destination=OUTPUT_GRAPH_PATH, output_graph_uri = f'https://amr.tetras-libre.fr/rdf/{test_file_name}/result'
print(f'\n -- Serialize test graph to {output_graph_path}')
graph.serialize(destination=output_graph_path,
format='turtle', format='turtle',
base=OUTPUT_GRAPH_URI) base=output_graph_uri)
#============================================================================== #==============================================================================
# Development Test # Development Test
#============================================================================== #==============================================================================
def test_search_pattern(graph): def test_search_pattern_1(graph):
query_code, pattern_set = rule_1.__search_pattern(graph)
query_code = rule_1.__rule_pattern_query_code(graph) print(f'\n ----- query code: {query_code}')
print(query_code)
pattern_set = rule_1.__search_pattern(graph)
print(f'\n ----- number of selection found: {len(pattern_set)}') print(f'\n ----- number of selection found: {len(pattern_set)}')
for selection in pattern_set: for selection in pattern_set:
result_str = f'>>> ' result_str = f'>>> '
result_str += f'{selection.property_net.n3(graph.namespace_manager)}' result_str += f'{selection.property_net.n3(graph.namespace_manager)}'
print(result_str) print(result_str)
return pattern_set return pattern_set
def test_search_pattern_2(graph):
query_code, pattern_set = rule_2.__search_pattern(graph)
print(f'\n ----- query code: {query_code}')
print(f'\n ----- number of selection found: {len(pattern_set)}')
for selection in pattern_set:
result_str = f'>>> '
result_str += f'{selection.phenomena_net.n3(graph.namespace_manager)}'
print(result_str)
return pattern_set
#============================================================================== #==============================================================================
# Unit Test # Unit Test
#============================================================================== #==============================================================================
def unittest_run_rule(graph, rule): def test_rule_application(test_file_name, graph, rule):
print('\n -- Rule Test') print('\n -- Rule Test')
rule_label, new_triple_list = rule(graph) rule_label, new_triple_list = rule(graph)
print(f' ----- label: {rule_label}') print(f' ----- label: {rule_label}')
print(f' ----- new_triple_list ({len(new_triple_list)}):')
add_triples_in_graph(graph, new_triple_list) add_triples_in_graph(test_file_name, graph, new_triple_list)
...@@ -131,31 +135,29 @@ def unittest_run_rule(graph, rule): ...@@ -131,31 +135,29 @@ def unittest_run_rule(graph, rule):
if __name__ == '__main__': if __name__ == '__main__':
print('\n *** Test Preparation ***') print('\n *** Test Preparation ***')
graph_1 = load_test_graph(TEST_FILE_NAME_1)
graph = load_test_graph() graph_2 = load_test_graph(TEST_FILE_NAME_2)
uriref = URIRef('net:compositeClass_orbit_hasManner_conjunction-OR') graph_3 = load_test_graph(TEST_FILE_NAME_3)
type_uriref = URIRef('net:Composite_Class_Net')
triple = (uriref, RDF.type, type_uriref)
phenomena_net_uri = 'net:phenomena_conjunction-OR_o3'
print('\n \n') print('\n \n')
print('\n ///////////////////// Extraction Rule 1')
print('\n *** Step Test ***') print('\n *** Step Test ***')
print('\n -- Step 1: search pattern') print('\n -- Step 1: Search Pattern')
rule_pattern_set = test_search_pattern(graph) pattern_set = test_search_pattern_1(graph_1)
for selection_1 in rule_pattern_set: for pattern in pattern_set:
print(f' -- Tests with {selection_1.property_net}') print(f' -- Tests with {pattern.property_net}')
print(f' -- Step 2: property net definition') print(f' -- Step 2: property net definition')
property_net = net.PropertyNet(graph, uri=selection_1.property_net) property_net = net.PropertyNet(graph_1, uri=pattern.property_net)
print_net_attributes(property_net) print_net_attributes(property_net)
print(f' -- Step 3: construction of composite property net') print(f' -- Step 3: construction of composite property net')
print(f' ----- Step 3a: initialisation') print(f' ----- Step 3a: initialisation')
composite_property_net = net.CompositePropertyNet(graph) composite_property_net = net.CompositePropertyNet(graph_1)
print(f' ----- Step 3b: composition') print(f' ----- Step 3b: composition')
composite_property_net.compose(property_net) composite_property_net.compose(property_net)
print_net_attributes(composite_property_net) print_net_attributes(composite_property_net)
...@@ -174,12 +176,26 @@ if __name__ == '__main__': ...@@ -174,12 +176,26 @@ if __name__ == '__main__':
triple_list = composite_property_net.generate_triple_definition() triple_list = composite_property_net.generate_triple_definition()
print(f' ----- triple_list ({len(triple_list)}):') print(f' ----- triple_list ({len(triple_list)}):')
for triple in triple_list: for triple in triple_list:
print_triple(triple) print_triple(graph_1, triple)
print('\n \n')
print('\n *** Unit Test ***')
test_rule_application(TEST_FILE_NAME_1, graph_1, rule.analyze_phenomena_polarity_1)
print('\n \n')
print('\n ///////////////////// Extraction Rule 2')
print('\n *** Step Test ***')
print('\n -- Step 1: Search Pattern')
pattern_set = test_search_pattern_2(graph_3)
print('\n \n') print('\n \n')
print('\n *** Unit Test ***') print('\n *** Unit Test ***')
unittest_run_rule(graph, rule.analyze_phenomena_polarity_1) test_rule_application(TEST_FILE_NAME_3, graph_3, rule.analyze_phenomena_polarity_2)
print('\n \n') print('\n \n')
print('\n *** - ***') 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