Skip to content
Snippets Groups Projects
Commit bfbd46f5 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Split STTL output by activity

parent 97b33b48
Branches
No related tags found
No related merge requests found
......@@ -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__":
......
......@@ -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 {
"""
+++
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment