Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Macao Legacy
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
MACAO
Macao Legacy
Commits
bfbd46f5
Commit
bfbd46f5
authored
1 year ago
by
Eliott Sammier
Browse files
Options
Downloads
Patches
Plain Diff
Split STTL output by activity
parent
97b33b48
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tetras_extraction/macao_12/script/src/export.py
+19
-3
19 additions, 3 deletions
tetras_extraction/macao_12/script/src/export.py
tetras_extraction/macao_12/script/templates/activite.rq
+0
-2
0 additions, 2 deletions
tetras_extraction/macao_12/script/templates/activite.rq
with
19 additions
and
5 deletions
tetras_extraction/macao_12/script/src/export.py
+
19
−
3
View file @
bfbd46f5
...
...
@@ -2,6 +2,7 @@
# (because py4j has no stubs and pretty much breaks type checkers)
import
atexit
import
re
import
subprocess
from
time
import
sleep
...
...
@@ -36,17 +37,32 @@ def main():
RDF
=
gateway
.
jvm
.
fr
.
inria
.
corese
.
core
.
logic
.
RDF
Transformer
=
gateway
.
jvm
.
fr
.
inria
.
corese
.
core
.
transform
.
Transformer
# Create graph, load ontology
#
==>
Create graph, load ontology
graph
=
Graph
()
ld
=
Load
.
create
(
graph
)
Property
.
set
(
Property
.
Value
.
DISABLE_OWL_AUTO_IMPORT
,
True
)
ld
.
parse
(
RDF_FULL_FILE
)
# Run STTL transformation
#
==>
Run STTL transformation
tr
=
Transformer
.
create
(
graph
,
MODULE_DIR
+
"
/../templates/
"
)
result
=
tr
.
transform
()
print
(
result
)
# ==> Split the result
regex
=
re
.
compile
(
r
"
^####### *?([\/\w]+)$
"
,
re
.
MULTILINE
)
parts
=
regex
.
split
(
result
)
# The parts list starts with the first non-delimiter string (which may be
# empty), then each capturing group result of the delimiter, then the second
# non-delimiter, and so on.
# With a pattern that has 1 group, its results are on odd-numbered indices.
for
i
in
range
(
1
,
len
(
parts
),
2
):
activity_path
=
parts
[
i
]
activity_content
=
parts
[
i
+
1
]
print
(
"
{} -> {}
"
.
format
(
activity_path
,
activity_content
[
1
:
100
].
replace
(
"
\n
"
,
"
\\
n
"
)
)
)
print
(
f
"
Found
{
len
(
parts
)
}
parts =>
{
(
len
(
parts
)
-
1
)
/
2
}
activities.
"
)
if
__name__
==
"
__main__
"
:
...
...
This diff is collapsed.
Click to expand it.
tetras_extraction/macao_12/script/templates/activite.rq
+
0
−
2
View file @
bfbd46f5
...
...
@@ -8,8 +8,6 @@ PREFIX owl: <http://www.w3.org/2002/07/owl#>
# and calls other specific templates when necessary
template
{
"####### "
st
:
call-template
(
mt
:
path
,
?subj
)
#FIXME: debug activity type
st
:
nl
()
st
:
call-template
(
mt
:
debug
,
?subj
)
format
{
"""
+++
...
...
This diff is collapsed.
Click to expand it.
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