Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tenet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
tenet
Commits
f81ae68f
Commit
f81ae68f
authored
2 years ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
Update CTS loader function (in tenet extraction)
parent
e1c9b53c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/tenet_extraction.py
+39
-16
39 additions, 16 deletions
lib/tenet_extraction.py
lib/transduction/rule.py
+1
-1
1 addition, 1 deletion
lib/transduction/rule.py
tenet.log
+13
-13
13 additions, 13 deletions
tenet.log
with
53 additions
and
30 deletions
lib/tenet_extraction.py
+
39
−
16
View file @
f81ae68f
...
...
@@ -19,6 +19,8 @@ import logging
import
glob
from
pathlib
import
Path
from
importlib.machinery
import
SourceFileLoader
import
importlib.util
import
importlib
from
.timer
import
timed
from
.transduction.rule
import
Rule
from
.transduction.sequence
import
Sequence
...
...
@@ -81,11 +83,31 @@ def load_rule_set(config, rule_dir, prefix_list):
try
:
rule_set
=
{}
target_ref
=
config
.
cts_dir
+
rule_dir
+
'
**/*.py
'
for
rule_filename
in
glob
.
iglob
(
target_ref
,
recursive
=
True
):
# -- Append rule paths to sys.path
path_glob_pattern
=
config
.
cts_dir
+
rule_dir
+
'
**/
'
for
rule_path
in
glob
.
iglob
(
path_glob_pattern
,
recursive
=
True
):
sys
.
path
.
append
(
rule_path
)
# -- Load rule modules
file_glob_pattern
=
config
.
cts_dir
+
rule_dir
+
'
**/*.py
'
for
rule_filename
in
glob
.
iglob
(
file_glob_pattern
,
recursive
=
True
):
if
'
query_builder
'
not
in
rule_filename
:
# -- old ---
# spec = importlib.util.spec_from_file_location(rule_module_name,
# rule_filename)
# rule_module = importlib.util.module_from_spec(spec)
# sys.modules[rule_module_name] = rule_module
# spec.loader.exec_module(rule_module)
# -- ---
# -- Import module
rule_module_name
=
Path
(
rule_filename
).
stem
rule_loader
=
SourceFileLoader
(
rule_module_name
,
rule_filename
)
rule_module
=
rule_loader
.
load_module
()
rule_module
=
importlib
.
import_module
(
f
'
{
rule_module_name
}
'
)
# -- Update rule set
if
hasattr
(
rule_module
,
'
rule_set
'
):
rule_def_set
=
rule_module
.
rule_set
new_rule_set
=
get_new_rule_set
(
rule_def_set
,
prefix_list
)
rule_set
.
update
(
new_rule_set
)
...
...
@@ -94,14 +116,15 @@ def load_rule_set(config, rule_dir, prefix_list):
except
:
logger
.
error
(
'
*** Error while loading rule set (load_rule_set) ***
'
)
logger
.
debug
(
'
----- target_ref: {0}
'
.
format
(
target_ref
))
logger
.
debug
(
'
----- rule_filename: {0}
'
.
format
(
rule_filename
))
logger
.
debug
(
'
----- rule_module_name: {0}
'
.
format
(
rule_module_name
))
logger
.
debug
(
'
----- rule_loader: {0}
'
.
format
(
rule_loader
))
logger
.
debug
(
'
----- rule_module: {0}
'
.
format
(
rule_module
))
logger
.
debug
(
'
----- len(rule_def_set): {0}
'
.
format
(
len
(
rule_def_set
)))
logger
.
debug
(
'
----- len(new_rule_set): {0}
'
.
format
(
len
(
new_rule_set
)))
logger
.
debug
(
'
----- len(rule_set): {0}
'
.
format
(
len
(
rule_set
)))
logger
.
debug
(
f
'
----- path_glob_pattern:
{
path_glob_pattern
}
'
)
logger
.
debug
(
f
'
----- sys.path:
{
sys
.
path
}
'
)
logger
.
debug
(
f
'
----- file_glob_pattern:
{
file_glob_pattern
}
'
)
logger
.
debug
(
f
'
----- rule_filename:
{
rule_filename
}
'
)
logger
.
debug
(
f
'
----- rule_module_name:
{
rule_module_name
}
'
)
logger
.
debug
(
f
'
----- rule_module:
{
rule_module
}
'
)
logger
.
debug
(
f
'
----- len(rule_def_set):
{
len
(
rule_def_set
)
}
'
)
logger
.
debug
(
f
'
----- len(new_rule_set):
{
len
(
new_rule_set
)
}
'
)
logger
.
debug
(
f
'
----- len(rule_set):
{
len
(
rule_set
)
}
'
)
...
...
This diff is collapsed.
Click to expand it.
lib/transduction/rule.py
+
1
−
1
View file @
f81ae68f
...
...
@@ -11,7 +11,7 @@
# Importing required modules
#==============================================================================
# --
#==============================================================================
...
...
This diff is collapsed.
Click to expand it.
tenet.log
+
13
−
13
View file @
f81ae68f
...
...
@@ -23,8 +23,8 @@
----- CTS directory: ./structure/cts/
----- target frame directory: ./input/targetFrameStructure/
----- input document directory: ./input/amrDocuments/
----- output directory: ./output/SolarSystemDev1-2022121
2
/
----- sentence output directory: ./output/SolarSystemDev1-2022121
2
/
----- output directory: ./output/SolarSystemDev1-2022121
3
/
----- sentence output directory: ./output/SolarSystemDev1-2022121
3
/
----- 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-2022121
2
/SolarSystemDev1.ttl
----- output file: ./output/SolarSystemDev1-2022121
3
/SolarSystemDev1.ttl
*** - ***
- INFO - -- Creating output target directory: ./output/SolarSystemDev1-2022121
2
/
- INFO - -- Creating output target directory: ./output/SolarSystemDev1-2022121
3
/
- 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-2022121
2
/SolarSystemDev1-1/SolarSystemDev1.ttl
- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-2022121
3
/SolarSystemDev1-1/SolarSystemDev1.ttl
- DEBUG - --- Ending Structure Preparation
- DEBUG - ----- Total Execution Time = 0:00:00.1
5523
5
- DEBUG - ----- Total Execution Time = 0:00:00.1
3206
5
- INFO - -- Loading Extraction Scheme (amr_scheme_1)
- DEBUG - ----- Step number: 3
- INFO - -- Loading Extraction Rules (amr_ctr/*)
...
...
@@ -95,7 +95,7 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_preprocessing
- DEBUG - ----- step: preprocessing
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
3
/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl
- DEBUG - ----- base: http://SolarSystemDev1/preprocessing
- INFO - ----- 212 triples extracted during preprocessing step
- INFO - -- Applying extraction step: transduction
...
...
@@ -176,7 +176,7 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_transduction
- DEBUG - ----- step: transduction
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
3
/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl
- DEBUG - ----- base: http://SolarSystemDev1/transduction
- INFO - ----- 376 triples extracted during transduction step
- INFO - -- Applying extraction step: generation
...
...
@@ -205,23 +205,23 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_generation
- DEBUG - ----- step: generation
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_generation.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
3
/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-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl)
- DEBUG - --- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
3
/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl)
- INFO -
*** Execution Time ***
----- Function: apply (lib.tenet_extraction)
----- Total Time: 0:00:0
9.171347
----- Process Time: 0:00:0
9.035147
----- Total Time: 0:00:0
7.356953
----- Process Time: 0:00:0
7.333204
*** - ***
- 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-2022121
2
/SolarSystemDev1_factoid.ttl)
- INFO - -- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
3
/SolarSystemDev1_factoid.ttl)
- INFO - === Done ===
This diff is collapsed.
Click to expand it.
Aurélien Lamercerie
@alam
mentioned in issue
#95 (closed)
·
2 years ago
mentioned in issue
#95 (closed)
mentioned in issue #95
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment