diff --git a/tetras_extraction/result/macao_3/macao_content.ttl b/tetras_extraction/result/macao_3/macao_content.ttl index 217151c70704370134d17611f6f88a1ba56d411c..df4f5d8e8daccc888be2fe10edf1146521d1c5d2 100644 --- a/tetras_extraction/result/macao_3/macao_content.ttl +++ b/tetras_extraction/result/macao_3/macao_content.ttl @@ -4833,7 +4833,7 @@ :id "seq502762" ; :index 0 ; :titre "Présentation" ; - rdfs:subClassOf :MacaoRoot . + rdfs:subClassOf :MosOrg1 . :seq602682 a :Module, owl:NamedIndividual ; @@ -4843,7 +4843,7 @@ :id "seq602682" ; :index 4 ; :titre "Mémentos" ; - rdfs:subClassOf :MacaoRoot . + rdfs:subClassOf :MosOrg1 . :pg1181 a :Activite, :ExerciceQC_QCU, @@ -5795,43 +5795,18 @@ :titre "Deuxième tâche" ; rdfs:subClassOf :act89909 . -:seq100407 a :Module, - owl:NamedIndividual ; - rdfs:label "Assimilation" ; - :__protege_display_name "01 | seq100407 | Assimilation" ; - :contientSousPartie :act153876, - :act704962, - :act761960, - :act957420 ; - :id "seq100407" ; - :index 1 ; - :titre "Assimilation" ; - rdfs:subClassOf :MacaoRoot . - -:seq68058 a :Module, - owl:NamedIndividual ; - rdfs:label "Proximité" ; - :__protege_display_name "02 | seq68058 | Proximité" ; - :contientSousPartie :act482478, - :act759984, - :act828642, - :act89909 ; - :id "seq68058" ; - :index 2 ; - :titre "Proximité" ; - rdfs:subClassOf :MacaoRoot . - -:seq906956 a :Module, +:MosOrg1 a :Module, owl:NamedIndividual ; - rdfs:label "Homophonie" ; - :__protege_display_name "03 | seq906956 | Homophonie" ; - :contientSousPartie :act56672, - :act687805, - :act765533, - :act838137 ; - :id "seq906956" ; - :index 3 ; - :titre "Homophonie" ; + rdfs:label "MACAO 3" ; + :__protege_display_name "00 | MosOrg1 | MACAO 3" ; + :contientModule :seq100407, + :seq502762, + :seq602682, + :seq68058, + :seq906956 ; + :id "MosOrg1" ; + :index 0 ; + :titre "MACAO 3" ; rdfs:subClassOf :MacaoRoot . :act56672 a :SousPartie, @@ -5965,6 +5940,45 @@ :titre "Troisième tâche (2)" ; rdfs:subClassOf :act89909 . +:seq100407 a :Module, + owl:NamedIndividual ; + rdfs:label "Assimilation" ; + :__protege_display_name "01 | seq100407 | Assimilation" ; + :contientSousPartie :act153876, + :act704962, + :act761960, + :act957420 ; + :id "seq100407" ; + :index 1 ; + :titre "Assimilation" ; + rdfs:subClassOf :MosOrg1 . + +:seq68058 a :Module, + owl:NamedIndividual ; + rdfs:label "Proximité" ; + :__protege_display_name "02 | seq68058 | Proximité" ; + :contientSousPartie :act482478, + :act759984, + :act828642, + :act89909 ; + :id "seq68058" ; + :index 2 ; + :titre "Proximité" ; + rdfs:subClassOf :MosOrg1 . + +:seq906956 a :Module, + owl:NamedIndividual ; + rdfs:label "Homophonie" ; + :__protege_display_name "03 | seq906956 | Homophonie" ; + :contientSousPartie :act56672, + :act687805, + :act765533, + :act838137 ; + :id "seq906956" ; + :index 3 ; + :titre "Homophonie" ; + rdfs:subClassOf :MosOrg1 . + :act89909 a :SousPartie, owl:NamedIndividual ; rdfs:label "Repérer des indices pertinents" ; diff --git a/tetras_extraction/script/src/extract.py b/tetras_extraction/script/src/extract.py index 564ccb5128496229e8f0d80a63ddd56c87dbb280..aa2cad4f455b13863f0ca7a4661b84349f6873ef 100644 --- a/tetras_extraction/script/src/extract.py +++ b/tetras_extraction/script/src/extract.py @@ -70,12 +70,17 @@ def parse_manifest(graph: Graph): org = ns_find(root, ".//organization") if org is None: raise ParseError("Missing node <organization> in manifest") - # For all top-level modules - for i, e in enumerate(ns_findall(org, "item")): - module = NS[e.get("identifier", default="None")] - parse_manifest_rec(graph, e) - graph.add((module, RDFS.subClassOf, NS["MacaoRoot"])) - add_index(graph, module, i) + + # The top-level element is the <organization> + root_module = NS[org.get("identifier", default="None")] + graph.add((root_module, RDFS.subClassOf, NS["MacaoRoot"])) + # Add a nice display name + if Context.version == "macao_3": + graph.add((root_module, NS["__protege_display_name"], Literal("MACAO 3"))) + else: + graph.add((root_module, NS["__protege_display_name"], Literal("MACAO"))) + # Recurse on the organization's items + parse_manifest_rec(graph, org) def parse_manifest_rec( @@ -84,7 +89,7 @@ def parse_manifest_rec( parentResource: URIRef | None = None, index: int | None = None, ): - """Parses a module `MosMod` from the manifest recursively, adding all its + """Parses a `MosOrg`, `MosMod` or `MosEtp` from the manifest recursively, adding all its descendants to the `graph` :param parentResource: parent element in the tree, as a `rdflib` resource :param index: index (order) among sibling elements @@ -126,8 +131,10 @@ def parse_manifest_rec( def is_module(id: str): - return (Context.version == "macao_12" and id.startswith("MosMod")) or ( - Context.version == "macao_3" and id.startswith("seq") + return ( + (Context.version == "macao_12" and id.startswith("MosMod")) + or (Context.version == "macao_3" and id.startswith("seq")) + or id.startswith("MosOrg") # the organization is just the top-level module )