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

make Python extract compatible with `full` mode

parent 8af83e9a
Branches
No related tags found
1 merge request!1Main
......@@ -13,7 +13,8 @@ elif [[ "$1" = "each" || "$1" = "full" ]]; then
shift
fi
export VERSION
# Version "each" is processed by calling the script itself once for each version
# Special version value "each" is processed by calling the script itself once
# for each actual version
if [[ "$VERSION" = "each" && "$1" != "shell" && "$1" != "status" && "$1" != "setup" ]]; then
echo "macao_12:" && "$0" 12 "$@"
echo "macao_3:" && "$0" 3 "$@"
......
This diff is collapsed.
@prefix : <http://www.semanticweb.org/eliott/ontologies/2024/4/macao/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://www.semanticweb.org/eliott/ontologies/2024/4/macao-content> a owl:Ontology ;
rdfs:label "macao-content" ;
owl:imports <http://www.semanticweb.org/eliott/ontologies/2024/4/macao> .
:seq100407 a :SousPartie,
owl:NamedIndividual ;
rdfs:label "Assimilation" ;
:__protege_display_name "01 | seq100407 | Assimilation" ;
:id "seq100407" ;
:index 1 ;
:titre "Assimilation" ;
rdfs:subClassOf :MacaoRoot .
:seq502762 a :SousPartie,
owl:NamedIndividual ;
rdfs:label "Présentation" ;
:__protege_display_name "00 | seq502762 | Présentation" ;
:id "seq502762" ;
:index 0 ;
:titre "Présentation" ;
rdfs:subClassOf :MacaoRoot .
:seq602682 a :SousPartie,
owl:NamedIndividual ;
rdfs:label "Mémentos" ;
:__protege_display_name "04 | seq602682 | Mémentos" ;
:id "seq602682" ;
:index 4 ;
:titre "Mémentos" ;
rdfs:subClassOf :MacaoRoot .
:seq68058 a :SousPartie,
owl:NamedIndividual ;
rdfs:label "Proximité" ;
:__protege_display_name "02 | seq68058 | Proximité" ;
:id "seq68058" ;
:index 2 ;
:titre "Proximité" ;
rdfs:subClassOf :MacaoRoot .
:seq906956 a :SousPartie,
owl:NamedIndividual ;
rdfs:label "Homophonie" ;
:__protege_display_name "03 | seq906956 | Homophonie" ;
:id "seq906956" ;
:index 3 ;
:titre "Homophonie" ;
rdfs:subClassOf :MacaoRoot .
......@@ -17,15 +17,14 @@ def env_path_or_rel_default(env_var: str, default: str) -> str:
# Path constants ###############################################################
MACAO_VERSION = environ.get("VERSION") or "full"
MODULE_DIR = path.dirname(path.realpath(__file__))
"""Absolute path of this module's directory"""
MACAO_ROOT = env_path_or_rel_default("MACAO_ROOT", "../../../..")
MACAO_ROOT = env_path_or_rel_default("MACAO_ROOT", "../../..")
"""Path to the Macao root directory"""
SOURCE_DIR = env_path_or_rel_default(
"SOURCES_DIR", "../../../../Basilisk/MACAO/macao_12"
)
SOURCE_DIR = env_path_or_rel_default("SOURCES_DIR", "../../../Basilisk/MACAO")
"""Path to the Macao source directory (i.e. the one with the manifest)"""
RESULT_DIR = env_path_or_rel_default("RESULTS_DIR", "../../result")
RESULT_DIR = env_path_or_rel_default("RESULTS_DIR", f"../../result/{MACAO_VERSION}")
"""Path to the directory containing various results (RDF, content, media...)"""
NEW_CONTENT_ROOT = env_path_or_rel_default(
"NEW_CONTENT_ROOT", RESULT_DIR + "/activities"
......
......@@ -66,7 +66,7 @@ def parse_manifest(graph: Graph):
modules hierarchy.
"""
# Parse with lxml
root = etree.parse(SOURCE_DIR + "/imsmanifest.xml", None).getroot()
root = etree.parse(source_dir + "/imsmanifest.xml", None).getroot()
org = ns_find(root, ".//organization")
if org is None:
raise ParseError("Missing node <organization> in manifest")
......@@ -122,7 +122,9 @@ def parse_manifest_rec(
if index is not None:
add_index(graph, subject, index)
# Parse list of pages
extract_mosetp.parse_mosetp(graph, f"{SOURCE_DIR}/sco/{id}.html", id)
extract_mosetp.parse_mosetp(
graph, f"{source_dir}/sco/{id}.html", id, f"{source_dir}/contenu/pages"
)
def compare_files(f1: str, f2: str):
......@@ -133,6 +135,9 @@ def compare_files(f1: str, f2: str):
)
source_dir = SOURCE_DIR
def main():
g = create_graph()
......@@ -144,6 +149,12 @@ def main():
with open(logfile, "w") as f:
print("", file=f)
if MACAO_VERSION == "full":
for version in [12, 3]:
global source_dir
source_dir = f"{SOURCE_DIR}/macao_{version}"
parse_manifest(g)
else:
parse_manifest(g)
export_graph(g)
......
......@@ -37,7 +37,7 @@ def generate_triples(
graph.add((mosetp, NS["contientActivite"], page))
def parse_mosetp(graph: Graph, filepath: str, id: str):
def parse_mosetp(graph: Graph, filepath: str, id: str, pages_dir: str):
"""Parse a subsection (`MosEtp###.html`) into the `graph`, creating
the child pages.
......@@ -64,7 +64,7 @@ def parse_mosetp(graph: Graph, filepath: str, id: str):
page_id = m.group(2)
generate_triples(graph, id, page_id, m.group(1), index)
# Call the page parser
parse_page(graph, f"{SOURCE_DIR}/contenu/pages/{page_id}.html", page_id)
parse_page(graph, f"{pages_dir}/{page_id}.html", page_id)
else:
log.warning(f"skipping page: regex found no match on line '{line}'")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment