Skip to content

Commit

Permalink
feat: Use full-text index for GTM (#1127)
Browse files Browse the repository at this point in the history
* using new GTM ontology (more schema.org) and lucene-index

* GTM ontology from skos to schema.org

* used more efficient STRSTARTS instead of CONTAINS

thanks for the suggestion @ddeboer
  • Loading branch information
coret committed Oct 8, 2023
1 parent 8ed839b commit e6046ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX sdo: <https://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gtm: <https://www.goudatijdmachine.nl/def#>
PREFIX schema: <https://schema.org/>
Expand All @@ -17,21 +17,18 @@ CONSTRUCT {
# Kapelstraat: <https://n2t.net/ark:/60537/b4ApaO>
VALUES ?uri { ?uris }
?uri a gtm:Straat ;
dcterms:identifier ?identifier ;
skos:prefLabel ?prefLabel .
FILTER (CONTAINS(STR(?uri), "ark:"))
sdo:identifier ?identifier ;
sdo:name ?prefLabel .
FILTER (STRSTARTS(STR(?uri), "https://n2t.net/ark:/60537/"))
OPTIONAL {
?uri skos:altLabel ?altLabel
}
OPTIONAL {
?uri hg:liesIn/schema:sameAs <http://sws.geonames.org/2755419/> # Gouda
BIND("Straat in Gouda" AS ?scopeNote)
?uri sdo:alternateName ?altLabel
}
BIND ( CONCAT( IF ( EXISTS { ?entity omeka:item_set <https://n2t.net/ark:/60537/bd75pg> }, "Verdwenen straat", "Straat" )," in Gouda") AS ?scopeNote )
OPTIONAL {
?uri hg:absorbedBy|hg:absorbed ?related_uri .
?related_uri a gtm:Straat ;
skos:prefLabel ?related_prefLabel .
FILTER (CONTAINS(STR(?related_uri), "ark:") && ?uri != ?related_uri )
sdo:name ?related_prefLabel .
FILTER (STRSTARTS(STR(?related_uri), "https://n2t.net/ark:/60537/") && ?uri != ?related_uri )
}
}
LIMIT 100
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX gtm: <https://www.goudatijdmachine.nl/def#>
PREFIX schema: <https://schema.org/>
PREFIX sdo: <https://schema.org/>
PREFIX hg: <http://rdf.histograph.io/>
PREFIX luc: <http://www.ontotext.com/connectors/lucene#>
PREFIX luc-index: <http://www.ontotext.com/connectors/lucene/instance#>
PREFIX omeka: <http://omeka.org/s/vocabs/o#>

CONSTRUCT {
?uri a skos:Concept ;
Expand All @@ -11,23 +13,25 @@ CONSTRUCT {
skos:scopeNote ?scopeNote ;
skos:related ?related_uri .
?related_uri skos:prefLabel ?related_prefLabel .
}
WHERE {
?uri a gtm:Straat ;
dcterms:identifier ?identifier ;
skos:prefLabel ?prefLabel .
OPTIONAL { ?uri skos:altLabel ?altLabel . }
OPTIONAL {
?uri hg:liesIn/schema:sameAs <http://sws.geonames.org/2755419/> # Gouda
BIND("Straat in Gouda" AS ?scopeNote)
}
} WHERE {
?search a luc-index:straten_index ;
luc:query ?query ;
luc:entities ?uri .

FILTER (STRSTARTS(STR(?uri), "https://n2t.net/ark:/60537/"))

?uri sdo:identifier ?identifier ;
sdo:name ?prefLabel ;
luc:score ?score .

BIND ( CONCAT( IF ( EXISTS { ?entity omeka:item_set <https://n2t.net/ark:/60537/bd75pg> }, "Verdwenen straat", "Straat" )," in Gouda") AS ?scopeNote )

OPTIONAL { ?uri sdo:alternateName ?altLabel . }

OPTIONAL {
?uri hg:absorbedBy|hg:absorbed ?related_uri .
?related_uri a gtm:Straat ;
skos:prefLabel ?related_prefLabel .
FILTER (CONTAINS(STR(?related_uri), "ark:") && ?uri != ?related_uri )
sdo:name ?related_prefLabel .
FILTER (STRSTARTS(STR(?related_uri), "https://n2t.net/ark:/60537/") && ?uri != ?related_uri )
}
FILTER (CONTAINS(STR(?uri), "ark:"))
FILTER (CONTAINS(LCASE(?prefLabel),?query) || CONTAINS(LCASE(?altLabel),?query) )
}
LIMIT 100
} ORDER BY DESC(?score) LIMIT 100

0 comments on commit e6046ba

Please sign in to comment.