Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Closed
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: 14 additions & 0 deletions e2e/mg_semantics_test/test_graphconfig/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Initialize graph configuration with custom parameters
CALL mg_semantics.graphconfig_init({
resourceLabel: "Resource",
classLabel: "Class",
subClassOfRel: "SCO",
uriProperty: "uri",
nameProperty: "name",
labelProperty: "label",
handleVocabUris: "SHORTEN",
keepLangTag: true,
handleMultival: "ARRAY",
handleRDFTypes: "LABELS"
})

28 changes: 28 additions & 0 deletions e2e/mg_semantics_test/test_graphconfig/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
query: >
CALL mg_semantics.graphconfig_show()
YIELD param, value
RETURN param, value
ORDER BY param

output:
- param: "classLabel"
value: "Class"
- param: "handleMultival"
value: "ARRAY"
- param: "handleRDFTypes"
value: "LABELS"
- param: "handleVocabUris"
value: "SHORTEN"
- param: "keepLangTag"
value: true
- param: "labelProperty"
value: "label"
- param: "nameProperty"
value: "name"
- param: "resourceLabel"
value: "Resource"
- param: "subClassOfRel"
value: "SCO"
- param: "uriProperty"
value: "uri"

27 changes: 27 additions & 0 deletions e2e/mg_semantics_test/test_inference_in_category/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Create hierarchy of categories from Library of Congress Subject Headings
CREATE (c:LCSHTopic { authoritativeLabel: "Crystallography", dbLabel: "Crystallography", identifier: "sh 85034498" })
CREATE (po:LCSHTopic { authoritativeLabel: "Physical optics", dbLabel: "PhysicalOptics", identifier: "sh 85095187" })
CREATE (s:LCSHTopic { authoritativeLabel: "Solids", dbLabel: "Solids", identifier: "sh 85124647" })
CREATE (co:LCSHTopic { authoritativeLabel: "Crystal optics", dbLabel: "CrystalOptics", identifier: "sh 85034488" })
CREATE (cr:LCSHTopic { authoritativeLabel: "Crystals", dbLabel: "Crystals", identifier: "sh 85034503" })
CREATE (d:LCSHTopic { authoritativeLabel: "Dimorphism (Crystallography)", dbLabel: "DimorphismCrystallography", identifier: "sh 2007001101" })
CREATE (i:LCSHTopic { authoritativeLabel: "Isomorphism (Crystallography)", dbLabel: "IsomorphismCrystallography", identifier: "sh 85068653" })

// Create hierarchy relationships
CREATE (c)<-[:NARROWER_THAN]-(co)-[:NARROWER_THAN]->(po)
CREATE (c)<-[:NARROWER_THAN]-(cr)-[:NARROWER_THAN]->(s)
CREATE (c)<-[:NARROWER_THAN]-(d)
CREATE (c)<-[:NARROWER_THAN]-(i)

// Create books with category relationships
CREATE (b1:Book { title: "Crystals and light", identifier: "2167673"})
CREATE (b2:Book { title: "Optical crystallography", identifier: "11916857"})
CREATE (b3:Book { title: "Isomorphism in minerals", identifier: "8096161"})
CREATE (b4:Book { title: "Crystals and life", identifier: "12873809"})
CREATE (b5:Book { title: "Highlights in applied mineralogy", identifier: "20234576"})

CREATE (b1)-[:HAS_SUBJECT]->(co)
CREATE (b2)-[:HAS_SUBJECT]->(co)
CREATE (b3)-[:HAS_SUBJECT]->(i)
CREATE (b4)-[:HAS_SUBJECT]->(cr)
CREATE (b5)-[:HAS_SUBJECT]->(cr)
13 changes: 13 additions & 0 deletions e2e/mg_semantics_test/test_inference_in_category/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query: >
MATCH (phyOpt:LCSHTopic { authoritativeLabel: "Physical optics"})
MATCH (book:Book)
WHERE mg_semantics.inference_in_category(book, phyOpt, { inCatRel: "HAS_SUBJECT", subCatRel: "NARROWER_THAN" })
RETURN book.identifier AS id, book.title AS title
ORDER BY book.identifier

output:
- id: "2167673"
title: "Crystals and light"
- id: "11916857"
title: "Optical crystallography"

28 changes: 28 additions & 0 deletions e2e/mg_semantics_test/test_inference_nodes_in_category/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Create hierarchy of categories from Library of Congress Subject Headings
CREATE (c:LCSHTopic { authoritativeLabel: "Crystallography", dbLabel: "Crystallography", identifier: "sh 85034498" })
CREATE (po:LCSHTopic { authoritativeLabel: "Physical optics", dbLabel: "PhysicalOptics", identifier: "sh 85095187" })
CREATE (s:LCSHTopic { authoritativeLabel: "Solids", dbLabel: "Solids", identifier: "sh 85124647" })
CREATE (co:LCSHTopic { authoritativeLabel: "Crystal optics", dbLabel: "CrystalOptics", identifier: "sh 85034488" })
CREATE (cr:LCSHTopic { authoritativeLabel: "Crystals", dbLabel: "Crystals", identifier: "sh 85034503" })
CREATE (d:LCSHTopic { authoritativeLabel: "Dimorphism (Crystallography)", dbLabel: "DimorphismCrystallography", identifier: "sh 2007001101" })
CREATE (i:LCSHTopic { authoritativeLabel: "Isomorphism (Crystallography)", dbLabel: "IsomorphismCrystallography", identifier: "sh 85068653" })

// Create hierarchy relationships
CREATE (c)<-[:NARROWER_THAN]-(co)-[:NARROWER_THAN]->(po)
CREATE (c)<-[:NARROWER_THAN]-(cr)-[:NARROWER_THAN]->(s)
CREATE (c)<-[:NARROWER_THAN]-(d)
CREATE (c)<-[:NARROWER_THAN]-(i)

// Create books with category relationships
CREATE (b1:Book { title: "Crystals and light", identifier: "2167673"})
CREATE (b2:Book { title: "Optical crystallography", identifier: "11916857"})
CREATE (b3:Book { title: "Isomorphism in minerals", identifier: "8096161"})
CREATE (b4:Book { title: "Crystals and life", identifier: "12873809"})
CREATE (b5:Book { title: "Highlights in applied mineralogy", identifier: "20234576"})

CREATE (b1)-[:HAS_SUBJECT]->(co)
CREATE (b2)-[:HAS_SUBJECT]->(co)
CREATE (b3)-[:HAS_SUBJECT]->(i)
CREATE (b4)-[:HAS_SUBJECT]->(cr)
CREATE (b5)-[:HAS_SUBJECT]->(cr)

13 changes: 13 additions & 0 deletions e2e/mg_semantics_test/test_inference_nodes_in_category/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query: >
MATCH (phyOpt:LCSHTopic { authoritativeLabel: "Physical optics"})
CALL mg_semantics.inference_nodes_in_category(phyOpt, { inCatRel: "HAS_SUBJECT", subCatRel: "NARROWER_THAN" })
YIELD node AS book
RETURN book.identifier AS id, book.title AS title
ORDER BY book.identifier

output:
- id: "2167673"
title: "Crystals and light"
- id: "11916857"
title: "Optical crystallography"

39 changes: 39 additions & 0 deletions e2e/mg_semantics_test/test_rdf_get_lang_value/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Initialize graph configuration
CALL mg_semantics.graphconfig_init({
resourceLabel: "Resource",
classLabel: "Class",
subClassOfRel: "SCO",
uriProperty: "uri",
nameProperty: "name",
labelProperty: "label",
handleVocabUris: "SHORTEN",
keepLangTag: true,
handleMultival: "ARRAY",
handleRDFTypes: "LABELS"
})

// Import RDF data with multilingual labels
CALL mg_semantics.rdf_import_inline('
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix ex: <http://example.org/products#> .

ex:Product a owl:Class ;
rdfs:label "Product"@en ;
rdfs:label "Produit"@fr ;
rdfs:label "Produkt"@de .

ex:Clothing a owl:Class ;
rdfs:subClassOf ex:Product ;
rdfs:label "Clothing"@en ;
rdfs:label "Vêtements"@fr ;
rdfs:label "Kleidung"@de .

ex:item1 a ex:Clothing ;
rdfs:label "Cotton T-Shirt"@en ;
rdfs:label "T-shirt en coton"@fr ;
rdfs:label "Baumwoll-T-Shirt"@de .
', "turtle")
YIELD triplesLoaded

18 changes: 18 additions & 0 deletions e2e/mg_semantics_test/test_rdf_get_lang_value/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
query: >
MATCH (item:Resource { name: "item1" })
RETURN
item.name AS name,
item.label AS allLabels,
mg_semantics.rdf_get_lang_value("en", item.label) AS labelEn,
mg_semantics.rdf_get_lang_value("fr", item.label) AS labelFr,
mg_semantics.rdf_get_lang_value("de", item.label) AS labelDe,
mg_semantics.rdf_get_lang_value("es", item.label) AS labelEs
ORDER BY item.name

output:
- name: "item1"
labelEn: "Cotton T-Shirt"
labelFr: "T-shirt en coton"
labelDe: "Baumwoll-T-Shirt"
labelEs: null

31 changes: 31 additions & 0 deletions e2e/mg_semantics_test/test_rdf_get_value/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Initialize graph configuration
CALL mg_semantics.graphconfig_init({
resourceLabel: "Resource",
classLabel: "Class",
subClassOfRel: "SCO",
uriProperty: "uri",
nameProperty: "name",
labelProperty: "label",
handleVocabUris: "SHORTEN",
keepLangTag: true,
handleMultival: "ARRAY",
handleRDFTypes: "LABELS"
})

// Import RDF data with multilingual labels
CALL mg_semantics.rdf_import_inline('
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix ex: <http://example.org/products#> .

ex:Product a owl:Class ;
rdfs:label "Product"@en ;
rdfs:label "Produit"@fr .

ex:item1 a ex:Product ;
rdfs:label "Cotton T-Shirt"@en ;
rdfs:label "T-shirt en coton"@fr .
', "turtle")
YIELD triplesLoaded

11 changes: 11 additions & 0 deletions e2e/mg_semantics_test/test_rdf_get_value/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
query: >
MATCH (item:Resource { name: "item1" })
UNWIND item.label AS langLabel
WITH mg_semantics.rdf_get_value(langLabel) AS extractedValue
RETURN extractedValue
ORDER BY extractedValue

output:
- extractedValue: "Cotton T-Shirt"
- extractedValue: "T-shirt en coton"

14 changes: 14 additions & 0 deletions e2e/mg_semantics_test/test_rdf_import_inline/input.cyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Initialize graph configuration
CALL mg_semantics.graphconfig_init({
resourceLabel: "Resource",
classLabel: "Class",
subClassOfRel: "SCO",
uriProperty: "uri",
nameProperty: "name",
labelProperty: "label",
handleVocabUris: "SHORTEN",
keepLangTag: true,
handleMultival: "ARRAY",
handleRDFTypes: "LABELS"
})

55 changes: 55 additions & 0 deletions e2e/mg_semantics_test/test_rdf_import_inline/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
query: >
CALL mg_semantics.rdf_import_inline('
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix ex: <http://example.org/products#> .

ex:Product a owl:Class ;
rdfs:label "Product"@en ;
rdfs:label "Produit"@fr ;
rdfs:label "Produkt"@de ;
rdfs:comment "A general product"@en .

ex:Clothing a owl:Class ;
rdfs:subClassOf ex:Product ;
rdfs:label "Clothing"@en ;
rdfs:label "Vêtements"@fr ;
rdfs:label "Kleidung"@de .

ex:Footwear a owl:Class ;
rdfs:subClassOf ex:Product ;
rdfs:label "Footwear"@en ;
rdfs:label "Chaussures"@fr ;
rdfs:label "Schuhe"@de .

ex:Shoes a owl:Class ;
rdfs:subClassOf ex:Footwear ;
rdfs:label "Shoes"@en ;
rdfs:label "Chaussures"@fr ;
rdfs:label "Schuhe"@de .

ex:LeatherShoes a owl:Class ;
rdfs:subClassOf ex:Shoes ;
rdfs:label "Leather Shoes"@en ;
rdfs:label "Chaussures en cuir"@fr ;
rdfs:label "Lederschuhe"@de .

ex:item1 a ex:LeatherShoes ;
rdfs:label "Classic Leather Boots"@en ;
rdfs:label "Bottes en cuir classiques"@fr ;
rdfs:label "Klassische Lederstiefel"@de ;
ex:price "99.99"^^xsd:decimal .

ex:item2 a ex:Clothing ;
rdfs:label "Cotton T-Shirt"@en ;
rdfs:label "T-shirt en coton"@fr ;
rdfs:label "Baumwoll-T-Shirt"@de ;
ex:price "19.99"^^xsd:decimal .
', "turtle")
YIELD triplesLoaded
RETURN triplesLoaded

output:
- triplesLoaded: 25

Loading
Loading