diff --git a/tetras_extraction/macao_12/script/src/export.py b/tetras_extraction/macao_12/script/src/export.py index 0cf12aaf3c2d0095e3a2124406320a3c3b83d0ab..f68ef248792f2ac3616af0e52b4e96acbbd63561 100644 --- a/tetras_extraction/macao_12/script/src/export.py +++ b/tetras_extraction/macao_12/script/src/export.py @@ -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__": diff --git a/tetras_extraction/macao_12/script/templates/activite.rq b/tetras_extraction/macao_12/script/templates/activite.rq index 057e09979d31420c68e71e32e0e4413e1e5d721c..cc33b24b146fae3359bb8bd0829f78316feae6de 100644 --- a/tetras_extraction/macao_12/script/templates/activite.rq +++ b/tetras_extraction/macao_12/script/templates/activite.rq @@ -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 { """ +++