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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
tenet
Commits
824bc2ff
Commit
824bc2ff
authored
2 years ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
Init dev for module construct query builder
parent
1b5e9eb2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/transduction/construct_query_builder.py
+120
-0
120 additions, 0 deletions
lib/transduction/construct_query_builder.py
tenet.log
+13
-13
13 additions, 13 deletions
tenet.log
with
133 additions
and
13 deletions
lib/transduction/construct_query_builder.py
0 → 100644
+
120
−
0
View file @
824bc2ff
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*
#==============================================================================
# TENET: Construct Query Builder
#------------------------------------------------------------------------------
# Module offering different functions to build SPARQL queries of transduction
# rules, for construct query part.
#==============================================================================
#==============================================================================
# Importing required modules
#==============================================================================
#==============================================================================
# Global Variable
#==============================================================================
# -- Default References
DEFAULT_NET_ID
=
'
?newNet
'
DEFAULT_NET_TYPE
=
'
Net
'
DEFAULT_SENTENCE_REF
=
'
?sentenceRef
'
DEFAULT_BASE_LEAF
=
'
?baseLeaf
'
DEFAULT_CLASS_NAME
=
'
?className
'
#==============================================================================
# Useful Functions
#==============================================================================
DATA_PROPERTY_TABLE
=
{
'
sentence_ref
'
:
'
net:hasStructure
'
,
'
class_name
'
:
'
net:hasClassName
'
}
#==============================================================================
# Useful Functions
#==============================================================================
def
get_net_type
(
net_type
):
if
not
net_type
.
startswith
(
'
net:
'
):
net_type
=
f
'
net:
{
net_type
}
'
return
net_type
def
get_net_data
(
net_id
,
**
net_data
):
data_str
=
""
for
data_ref
,
data_val
in
net_data
.
items
():
data_property
=
DATA_PROPERTY_TABLE
[
f
'
{
data_ref
}
'
]
data_str
+=
f
"
{
net_id
}
{
data_property
}
{
data_val
}
.
\n
"
return
data_str
#==============================================================================
# Main Functions
#==============================================================================
def
new_net
(
net_id
=
DEFAULT_NET_ID
,
net_type
=
DEFAULT_NET_TYPE
,
base_leaf
=
DEFAULT_BASE_LEAF
,
**
net_data
):
return
f
"""
# -- New Class Net
{
net_id
}
a
{
get_net_type
(
net_type
)
}
.
{
net_id
}
net:coverBaseNode
{
base_leaf
}
.
{
get_net_data
(
net_id
,
**
net_data
)
}
"""
def
relation_propagation
(
net_id
=
DEFAULT_NET_ID
):
return
f
"""
# -- Propagation of relations (from nodes to nets)
?inRelationRole a net:Relation.
?inNet ?inRelationRole
{
net_id
}
.
?outRelationRole a net:Relation.
{
net_id
}
?outRelationRole ?outNet.
"""
#==============================================================================
# Development Test
#==============================================================================
if
__name__
==
'
__main__
'
:
print
(
'
\n
'
+
'
*** Development Test ***
'
)
print
(
'
\n
'
+
'
-- test: get_net_data()
'
)
test_str
=
get_net_data
(
'
?newNet
'
,
class_name
=
'
?conceptName
'
)
print
(
test_str
)
print
(
'
\n
'
+
'
-- test: new_net
'
)
test_str
=
new_net
(
class_name
=
'
?conceptName
'
)
print
(
test_str
)
test_str
=
new_net
(
net_type
=
'
Atom_Class_Net
'
,
class_name
=
'
?conceptName
'
)
print
(
test_str
)
print
(
'
\n
'
+
'
-- test: update a test query
'
)
test_query
=
f
"""
[...]
CONSTRUCT {{
{
new_net
(
net_type
=
'
Atom_Class_Net
'
,
sentence_ref
=
'
?sentenceRef
'
,
class_name
=
'
?conceptName
'
)
}
{
relation_propagation
()
}
}}
WHERE {{
clause_1
clause_2
[...]
binding
}}
"""
print
(
test_query
)
print
(
'
\n
'
+
'
*** - ***
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tenet.log
+
13
−
13
View file @
824bc2ff
...
@@ -23,8 +23,8 @@
...
@@ -23,8 +23,8 @@
----- CTS directory: ./structure/cts/
----- CTS directory: ./structure/cts/
----- target frame directory: ./input/targetFrameStructure/
----- target frame directory: ./input/targetFrameStructure/
----- input document directory: ./input/amrDocuments/
----- input document directory: ./input/amrDocuments/
----- output directory: ./output/SolarSystemDev1-2022121
0
/
----- output directory: ./output/SolarSystemDev1-2022121
2
/
----- sentence output directory: ./output/SolarSystemDev1-2022121
0
/
----- sentence output directory: ./output/SolarSystemDev1-2022121
2
/
----- SHACL binary directory: ./lib/shacl-1.3.2/bin
----- SHACL binary directory: ./lib/shacl-1.3.2/bin
-- Config File Definition
-- Config File Definition
----- schema file: ./structure/amr-rdf-schema.ttl
----- schema file: ./structure/amr-rdf-schema.ttl
...
@@ -44,9 +44,9 @@
...
@@ -44,9 +44,9 @@
----- 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: ./output/SolarSystemDev1-2022121
0
/SolarSystemDev1.ttl
----- output file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1.ttl
*** - ***
*** - ***
- INFO - -- Creating output target directory: ./output/SolarSystemDev1-2022121
0
/
- INFO - -- Creating output target directory: ./output/SolarSystemDev1-2022121
2
/
- DEBUG - -- Counting number of graph files (sentences)
- DEBUG - -- Counting number of graph files (sentences)
- DEBUG - ----- Graph count: 1
- DEBUG - ----- Graph count: 1
- INFO - === Extraction Processing using New TENET Engine ===
- INFO - === Extraction Processing using New TENET Engine ===
...
@@ -64,9 +64,9 @@
...
@@ -64,9 +64,9 @@
- DEBUG - ----- Sentence Loading
- DEBUG - ----- Sentence Loading
- DEBUG - -------- ./input/amrDocuments/dev/solar-system-1/SSC-01-01.stog.amr.ttl (614)
- DEBUG - -------- ./input/amrDocuments/dev/solar-system-1/SSC-01-01.stog.amr.ttl (614)
- DEBUG - --- Export work graph as turtle
- DEBUG - --- Export work graph as turtle
- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-2022121
0
/SolarSystemDev1-1/SolarSystemDev1.ttl
- DEBUG - ----- Work graph file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1.ttl
- DEBUG - --- Ending Structure Preparation
- DEBUG - --- Ending Structure Preparation
- DEBUG - ----- Total Execution Time = 0:00:00.1
20758
- DEBUG - ----- Total Execution Time = 0:00:00.1
55235
- INFO - -- Loading Extraction Scheme (amr_scheme_1)
- INFO - -- Loading Extraction Scheme (amr_scheme_1)
- DEBUG - ----- Step number: 3
- DEBUG - ----- Step number: 3
- INFO - -- Loading Extraction Rules (amr_ctr/*)
- INFO - -- Loading Extraction Rules (amr_ctr/*)
...
@@ -95,7 +95,7 @@
...
@@ -95,7 +95,7 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_preprocessing
- DEBUG - --- Serializing graph to SolarSystemDev1_preprocessing
- DEBUG - ----- step: preprocessing
- DEBUG - ----- step: preprocessing
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
0
/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_preprocessing.ttl
- DEBUG - ----- base: http://SolarSystemDev1/preprocessing
- DEBUG - ----- base: http://SolarSystemDev1/preprocessing
- INFO - ----- 212 triples extracted during preprocessing step
- INFO - ----- 212 triples extracted during preprocessing step
- INFO - -- Applying extraction step: transduction
- INFO - -- Applying extraction step: transduction
...
@@ -176,7 +176,7 @@
...
@@ -176,7 +176,7 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_transduction
- DEBUG - --- Serializing graph to SolarSystemDev1_transduction
- DEBUG - ----- step: transduction
- DEBUG - ----- step: transduction
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
0
/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_transduction.ttl
- DEBUG - ----- base: http://SolarSystemDev1/transduction
- DEBUG - ----- base: http://SolarSystemDev1/transduction
- INFO - ----- 376 triples extracted during transduction step
- INFO - ----- 376 triples extracted during transduction step
- INFO - -- Applying extraction step: generation
- INFO - -- Applying extraction step: generation
...
@@ -205,23 +205,23 @@
...
@@ -205,23 +205,23 @@
- DEBUG - --- Serializing graph to SolarSystemDev1_generation
- DEBUG - --- Serializing graph to SolarSystemDev1_generation
- DEBUG - ----- step: generation
- DEBUG - ----- step: generation
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- id: SolarSystemDev1
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
0
/SolarSystemDev1-1/SolarSystemDev1_generation.ttl
- DEBUG - ----- work_file: ./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_generation.ttl
- DEBUG - ----- base: http://SolarSystemDev1/generation
- DEBUG - ----- base: http://SolarSystemDev1/generation
- INFO - ----- 159 triples extracted during generation step
- INFO - ----- 159 triples extracted during generation step
- INFO - -- Result: file containing only the factoids
- INFO - -- Result: file containing only the factoids
- DEBUG - --- Making factoid graph with the last step result
- DEBUG - --- Making factoid graph with the last step result
- DEBUG - ----- Number of factoids: 176
- DEBUG - ----- Number of factoids: 176
- DEBUG - ----- Graph base: http://SolarSystemDev1/factoid
- DEBUG - ----- Graph base: http://SolarSystemDev1/factoid
- DEBUG - --- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
0
/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl)
- DEBUG - --- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
2
/SolarSystemDev1-1/SolarSystemDev1_factoid.ttl)
- INFO -
- INFO -
*** Execution Time ***
*** Execution Time ***
----- Function: apply (lib.tenet_extraction)
----- Function: apply (lib.tenet_extraction)
----- Total Time: 0:00:0
7.319353
----- Total Time: 0:00:0
9.171347
----- Process Time: 0:00:0
7.293875
----- Process Time: 0:00:0
9.035147
*** - ***
*** - ***
- INFO - === Final Ontology Generation ===
- INFO - === Final Ontology Generation ===
- INFO - -- Making complete factoid graph by merging sentence factoid graphs
- INFO - -- Making complete factoid graph by merging sentence factoid graphs
- INFO - ----- Total factoid number: 176
- INFO - ----- Total factoid number: 176
- INFO - ----- Graph base: http://SolarSystemDev1/factoid
- INFO - ----- Graph base: http://SolarSystemDev1/factoid
- INFO - -- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
0
/SolarSystemDev1_factoid.ttl)
- INFO - -- Serializing graph to factoid file (./output/SolarSystemDev1-2022121
2
/SolarSystemDev1_factoid.ttl)
- INFO - === Done ===
- INFO - === Done ===
This diff is collapsed.
Click to expand it.
Aurélien Lamercerie
@alam
mentioned in issue
#122 (closed)
·
2 years ago
mentioned in issue
#122 (closed)
mentioned in issue #122
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