Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
- name: Validate ontology TTL
run: rapper -i turtle ontology/ontology.ttl -c
- name: Validate knowledge graph TTL
run: rapper -i turtle ontology/graph.ttl -c
- name: Validate individual graphs TTLs
run: rapper -i turtle graph/graph.ttl -c
- name: Validate individual subgraphs TTLs
run: |
for graph in ontology/graphs/*.ttl; do
rapper -i turtle -c "$graph"
for subgraph in graph/subgraphs/*.ttl; do
rapper -i turtle -c "$subgraph"
done
test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,12 +63,14 @@ jobs:
git fetch --tags --prune && \
git reset --hard @{upstream} && \
git clean -d --force"
- name: Generate versioned ontology files
- name: Generate versioned ontology and graph files
run: |
ssh -p${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} \
"cd ${{ secrets.SSH_WORKING_DIR }} && \
for tag in \$(git tag --sort=version:refname); do
mkdir -p ontology/\$tag
mkdir -p graph/\$tag

git show \$tag:ontology/ontology.ttl > ontology/\$tag/ontology.ttl
git show \$tag:ontology/graph.ttl > ontology/\$tag/graph.ttl
git show \$tag:graph/graph.ttl > graph/\$tag/graph.ttl
done"
8 changes: 4 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
- name: Validate ontology TTL
run: rapper -i turtle ontology/ontology.ttl -c
- name: Validate knowledge graph TTL
run: rapper -i turtle ontology/graph.ttl -c
- name: Validate individual graphs TTLs
run: rapper -i turtle graph/graph.ttl -c
- name: Validate individual subgraphs TTLs
run: |
for graph in ontology/graphs/*.ttl; do
rapper -i turtle -c "$graph"
for subgraph in graph/subgraphs/*.ttl; do
rapper -i turtle -c "$subgraph"
done

check-rdf-issues:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ venv.bak/

# ===== PROJECT =====================
ontology/v*
graph/v*
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13.12
3.13.13
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# The Monomyth Ontology

Group project for the Knowledge Representation and Extraction 2024/25 course.

The site of the project is live at [monomyth.metamuses.org](https://monomyth.metamuses.org).

The **Monomyth Ontology** is an RDF/OWL ontology for modeling narrative works
Expand Down Expand Up @@ -30,14 +28,14 @@ The most important components are:
novel, or other narrative form.
* **Monomyth Expression**: the specific interpretation of a narrative work
through the hero's journey framework.
* **Acts and Stages**: the three broad phases of the monomyth, Departure,
* **Acts** and **Stages**: the three broad phases of the monomyth, Departure,
Initiation, and Return, articulated through Campbell's seventeen stages.
* **Stage Realizations**: the concrete moments in a story where a monomyth stage
is realized, described, evaluated, and placed in the narrative sequence.
* **Characters and Archetypes**: the figures involved in the journey, connected
to functional roles such as hero, mentor, herald, shadow, ally, trickster, or
threshold guardian, based on Christopher Vogler's adaptation for screenwriting
of Campbell's work.
* **Characters** and **Archetypes**: the figures involved in the journey,
connected to functional roles such as hero, mentor, herald, shadow, ally,
trickster, or threshold guardian, based on Christopher Vogler's adaptation for
screenwriting of Campbell's work.
* **Fit Qualities**: a graded vocabulary for expressing how closely a narrative
moment corresponds to a monomyth stage, from perfect alignment to weak, absent,
or inverted realization.
Expand All @@ -48,8 +46,8 @@ forms of variation.
mapping, especially where the relationship between the story and the monomyth
requires nuance rather than simple classification.

## Graphical framework
![Monomyth Ontology Graphical Framework](https://raw.githubusercontent.com/metamuses/monomyth/refs/heads/main/graphical_framework/ontology.png)
![Monomyth Ontology Graffoo](https://raw.githubusercontent.com/metamuses/monomyth/refs/heads/main/graffoo/ontology.png)

## Knowledge graphs

The full knowledge graph is available at [monomyth.metamuses.org/graph/](https://monomyth.metamuses.org/graph/).
Expand All @@ -63,7 +61,7 @@ ontology.

Analyzed works include:

* **Oedipus Myth**: a classical myth about a king whose attempt to escape
* **Oedipus**: a classical myth about a king whose attempt to escape
prophecy leads him toward the discovery of his own hidden guilt.
* **Aeneid**: a Latin epic poem about Aeneas's journey from the ruins of
Troy toward the foundation of a new destiny in Italy.
Expand Down
13 changes: 7 additions & 6 deletions config/monomyth.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ server {
try_files /ontology/ontology.ttl =404;
}

# ===== GRAPH ============================
# serve subgraphs TTL for website modals
location ~ ^/graphs/(.+\.ttl)$ {
# ===== SUBGRAPHS ============================
# serve subgraphs files with local hosting
location ~ ^/subgraphs/(.+\.ttl)$ {
add_header Access-Control-Allow-Origin *;
add_header Cache-Control "public, max-age=3600";
default_type text/turtle;

try_files /ontology/graphs/$1 =404;
try_files /graph/subgraphs/$1 =404;
}

# ===== GRAPH ============================
# redirect /graph to /graph/
location = /graph {
return 301 /graph/;
Expand All @@ -90,7 +91,7 @@ server {
add_header Cache-Control "public, max-age=7776000";
default_type text/turtle;

rewrite ^/([0-9]+\.[0-9]+)/graph\.ttl$ /ontology/v$1/graph.ttl break;
rewrite ^/([0-9]+\.[0-9]+)/graph\.ttl$ /graph/v$1/graph.ttl break;
}

# serve main graph endpoint
Expand All @@ -99,7 +100,7 @@ server {
add_header Cache-Control "public, max-age=3600";
default_type text/turtle;

try_files /ontology/graph.ttl =404;
try_files /graph/graph.ttl =404;
}

# ===== SPARQL ===========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
<y:Geometry height="35.0" width="97.0949682107173" x="760.2648813712733" y="164.19319562886375"/>
<y:Fill color="#CCFFCC" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">xsd:string</y:NodeLabel>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">rdfs:Literal</y:NodeLabel>
<y:Shape type="parallelogram"/>
</y:ShapeNode>
</data>
Expand Down Expand Up @@ -218,7 +218,7 @@
<y:Geometry height="35.0" width="97.0949682107173" x="744.5531968033548" y="224.27224625083954"/>
<y:Fill color="#CCFFCC" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">xsd:string</y:NodeLabel>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">rdfs:Literal</y:NodeLabel>
<y:Shape type="parallelogram"/>
</y:ShapeNode>
</data>
Expand Down Expand Up @@ -285,7 +285,7 @@ http://www.w3.org/2001/XMLSchema#</y:NodeLabel>
<y:Geometry height="22.2421875" width="31.4345703125" x="-4.490958670815928" y="-259.45344890024734"/>
<y:Fill hasColor="false" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="left" autoSizePolicy="content" borderDistance="0.0" fontFamily="Dialog" fontSize="11" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="68.775390625" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="71.04736328125" x="-19.806396484375" xml:space="preserve" y="-23.2666015625">monomyth:
<y:NodeLabel alignment="left" autoSizePolicy="content" borderDistance="0.0" fontFamily="Dialog" fontSize="11" fontStyle="bold" hasBackgroundColor="false" hasLineColor="false" height="68.775390625" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="71.04736328125" x="-19.806396484375" xml:space="preserve" y="-23.2666015625">monomyth:
creon:
rdfs:
rdf:
Expand Down Expand Up @@ -676,7 +676,7 @@ xsd:</y:NodeLabel>
<y:Geometry height="35.0" width="97.0949682107173" x="774.7648813712733" y="68.47503372187379"/>
<y:Fill color="#CCFFCC" transparent="false"/>
<y:BorderStyle color="#000000" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">xsd:string</y:NodeLabel>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="11" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="16.955078125" horizontalTextPosition="center" iconTextGap="4" modelName="internal" modelPosition="c" textColor="#000000" verticalTextPosition="bottom" visible="true" width="57.84521484375" x="19.62487668348365" xml:space="preserve" y="9.0224609375">rdfs:Literal</y:NodeLabel>
<y:Shape type="parallelogram"/>
</y:ShapeNode>
</data>
Expand Down
Binary file added graffoo/ontology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed graphical_framework/ontology.png
Binary file not shown.
6 changes: 3 additions & 3 deletions ontology/ontology.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,13 @@ monomyth:fitNote a owl:DatatypeProperty ;
rdfs:comment """An annotation explaining nuances, tensions, or interpretive choices in the stage
mapping."""@en ;
rdfs:domain monomyth:StageRealization ;
rdfs:range xsd:string .
rdfs:range rdfs:Literal .

monomyth:realizationDescription a owl:DatatypeProperty ;
rdfs:label "realization description"@en ;
rdfs:comment """A prose description of how a stage is realized in a specific narrative."""@en ;
rdfs:domain monomyth:StageRealization ;
rdfs:range xsd:string .
rdfs:range rdfs:Literal .

monomyth:stageRealizationOrder a owl:DatatypeProperty,
owl:FunctionalProperty ;
Expand Down Expand Up @@ -492,7 +492,7 @@ monomyth:divergenceRationale a owl:DatatypeProperty ;
behind a divergence from the monomyth template. Complements a fit note on a stage realization by
focusing specifically on the motivation for the departure."""@en ;
rdfs:domain creon:ProductDivergence ;
rdfs:range xsd:string .
rdfs:range rdfs:Literal .

# ==============================================================================
# NAMED INDIVIDUALS
Expand Down
6 changes: 3 additions & 3 deletions scripts/check_rdf_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Check Turtle graph files for ontology vocabulary consistency.

The script loads ontology/ontology.ttl to discover declared ontology terms,
then loads every .ttl file under ontology/graphs/ and validates Turtle syntax.
then loads every .ttl file under graph/subgraphs/ and validates Turtle syntax.

It reports three kinds of issues:
- Unknown predicates: ontology predicates used in graphs but not declared as properties
Expand All @@ -30,7 +30,7 @@
ROOT_DIR = Path(__file__).resolve().parent.parent

ONTOLOGY_FILE = ROOT_DIR / "ontology" / "ontology.ttl"
GRAPH_DIR = ROOT_DIR / "ontology" / "graphs"
SUBGRAPHS_DIR = ROOT_DIR / "graph" / "subgraphs"

ONTOLOGY_URI = "https://monomyth.metamuses.org/ontology#"

Expand Down Expand Up @@ -113,7 +113,7 @@ def collect_declared_terms(rdf_graph):
used_classes = {}
used_object_terms = {}

for graph_file in sorted(GRAPH_DIR.glob("**/*.ttl")):
for graph_file in sorted(SUBGRAPHS_DIR.glob("**/*.ttl")):
print(f"Loading {graph_file}")

file_graph = Graph()
Expand Down
6 changes: 3 additions & 3 deletions scripts/check_rdf_inverses.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

The script loads ontology/ontology.ttl to discover owl:inverseOf declarations
and rdfs:subPropertyOf relationships, then loads every .ttl file under
ontology/graphs/ and validates Turtle syntax.
graph/subgraphs/ and validates Turtle syntax.

It checks that every use of a property with an inverse is mirrored by the
corresponding inverse triple. Subproperties are handled automatically, so a
Expand All @@ -29,7 +29,7 @@
ROOT_DIR = Path(__file__).resolve().parent.parent

ONTOLOGY_FILE = ROOT_DIR / "ontology" / "ontology.ttl"
GRAPH_DIR = ROOT_DIR / "ontology" / "graphs"
SUBGRAPHS_DIR = ROOT_DIR / "graph" / "subgraphs"

MONOMYTH = Namespace("https://monomyth.metamuses.org/ontology#")

Expand Down Expand Up @@ -92,7 +92,7 @@ def has_any_triple(graph, s, ps, o):

data = Graph()

for ttl in sorted(GRAPH_DIR.glob("**/*.ttl")):
for ttl in sorted(SUBGRAPHS_DIR.glob("**/*.ttl")):
print(f"Loading {ttl}")
parse_turtle_file(data, ttl)

Expand Down
8 changes: 4 additions & 4 deletions scripts/check_rdf_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Check Turtle graph files for RDF consistency issues.

The script loads every .ttl file under ontology/graphs/, validates Turtle
The script loads every .ttl file under graph/subgraphs/, validates Turtle
syntax, and inspects local resources belonging to the configured BASE_URI.

It reports two kinds of issues:
Expand All @@ -23,16 +23,16 @@
ROOT_DIR = Path(__file__).resolve().parent.parent

# Define the directory containing Turtle graph files
GRAPHS_DIR = ROOT_DIR / "ontology" / "graphs"
SUBGRAPHS_DIR = ROOT_DIR / "graph" / "subgraphs"

# Define the URI prefix used to identify local project resources
BASE_URI = "https://monomyth.metamuses.org/graph/"

# Create the RDF graph that will contain all parsed triples
g = Graph()

# Load every Turtle file in the graphs directory
for ttl_file in sorted(GRAPHS_DIR.glob("**/*.ttl")):
# Load every Turtle file in the subgraphs directory
for ttl_file in sorted(SUBGRAPHS_DIR.glob("**/*.ttl")):
print(f"Loading {ttl_file}")

# Stop immediately if any Turtle file has invalid syntax
Expand Down
14 changes: 7 additions & 7 deletions scripts/merge_subgraphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""
Merge selected Turtle subgraph files into the main project graph.

The script preserves the header/prefix section of ontology/graph.ttl, removes
The script preserves the header/prefix section of graph/graph.ttl, removes
any previously merged graph body, then appends the body of each configured
subgraph from ontology/graphs/.
subgraph from graph/subgraphs/.

Each subgraph is expected to contain a prefix/header section followed by a
blank line and then its graph triples. Only the content after the first blank
Expand All @@ -22,11 +22,11 @@
ROOT_DIR = Path(__file__).resolve().parent.parent

# Define the main graph and subgraphs paths
MAIN_GRAPH = ROOT_DIR / "ontology" / "graph.ttl"
SUBGRAPHS_DIR = ROOT_DIR / "ontology" / "graphs"
MAIN_GRAPH = ROOT_DIR / "graph" / "graph.ttl"
SUBGRAPHS_DIR = ROOT_DIR / "graph" / "subgraphs"

# List subgraphs in merge order.
SUBGRAPH_FILES = [
SUBGRAPHS = [
"oedipus.ttl",
"aeneid.ttl",
"rostam-haft-khan.ttl",
Expand All @@ -38,7 +38,7 @@
"the-matrix.ttl",
"walter-mitty.ttl",
"lady-bird.ttl",
"sableFable.ttl",
"sable-fable.ttl",
]

# Define the separator between subgraphs
Expand All @@ -63,7 +63,7 @@
# Collect subgraph bodies before rewriting the main graph
subgraph_bodies = []

for filename in SUBGRAPH_FILES:
for filename in SUBGRAPHS:
path = SUBGRAPHS_DIR / filename

# Skip missing subgraphs
Expand Down
Binary file added website/img/martina.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/img/maryam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/img/nicol.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/img/tommaso.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading