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

Fix import issues for generated ontology

parent 9745fa47
Branches
No related tags found
No related merge requests found
# JetBrains IDE config
**/.idea
# Protégé catalog file (unreliable changes)
**/catalog-v001.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog prefer="public" xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<group id="Folder Repository, directory=, recursive=true, Auto-Update=true, version=2" prefer="public" xml:base=""/>
</catalog>
......@@ -3,6 +3,10 @@
@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> .
:MosMod951 a :Module,
owl:NamedIndividual ;
rdfs:label "Présentation" ;
......@@ -2995,6 +2999,3 @@
:titre "> Utiliser les symboles phonétiques" ;
rdfs:subClassOf :MosMod341 .
[] a owl:Ontology ;
owl:imports : .
# Python cache and runtime env
__pycache__/
venv/
from pprint import pprint
from typing import Optional
from rdflib import RDFS, Graph, BNode, URIRef, Literal
from rdflib.namespace import OWL, RDF
from lxml import etree
from rdflib import RDFS, Graph, Literal, URIRef
from rdflib.namespace import OWL, RDF
import extract_mosetp
from common import *
# All common constants are in a dedicated module
from constants import *
from common import *
import extract_mosetp
import extract_page
schema_ontology_uri = URIRef(
"http://www.semanticweb.org/eliott/ontologies/2024/4/macao"
)
content_ontology_uri = URIRef(
"http://www.semanticweb.org/eliott/ontologies/2024/4/macao-content"
)
def dump_graph(g: Graph):
......@@ -28,9 +35,10 @@ def export_graph(g: Graph):
"""Exports the graph to `OUT_FILE`, with OWL imports to include
the schema file when loaded as an ontology
"""
imports = BNode()
g.add((imports, RDF.type, OWL.Ontology))
g.add((imports, OWL.imports, URIRef(NS)))
this_onto = content_ontology_uri
g.add((this_onto, RDF.type, OWL.Ontology))
g.add((this_onto, RDFS.label, Literal("macao-content")))
g.add((this_onto, OWL.imports, schema_ontology_uri))
g.serialize(OUT_FILE, "turtle", base=NS)
print(f"Exported {len(g)} triples to {OUT_FILE}.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment