From 8d5affa8ebacaa4b3e6d14f7db4404ce59afcab4 Mon Sep 17 00:00:00 2001 From: Esko Ikkala <esko.ikkala@aalto.fi> Date: Tue, 26 Jun 2018 13:26:16 +0300 Subject: [PATCH] Improve tgn suggestions, use only simple suggestions --- src/server/Datasets.js | 129 ++++++++++++++++++++++------------------ src/server/SparqlApi.js | 1 - 2 files changed, 71 insertions(+), 59 deletions(-) diff --git a/src/server/Datasets.js b/src/server/Datasets.js index 2eb978c2..05c8014c 100644 --- a/src/server/Datasets.js +++ b/src/server/Datasets.js @@ -4,24 +4,24 @@ module.exports = { 'shortTitle': 'KMN', 'timePeriod': '1922-1944', 'endpoint': 'http://ldf.fi/warsa/sparql', - 'suggestionQuery': ` - PREFIX text: <http://jena.apache.org/text#> - PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> - PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - PREFIX skos: <http://www.w3.org/2004/02/skos/core#> - PREFIX gs: <http://www.opengis.net/ont/geosparql#> - SELECT DISTINCT ?label (COUNT(?s) AS ?count) - WHERE { - GRAPH <http://ldf.fi/warsa/places/karelian_places> { - (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . - } - ?s skos:prefLabel ?lbl . - BIND(STR(?lbl) AS ?label) - } - GROUP BY ?label - ORDER BY DESC(MAX(?score)) ?label - LIMIT 50 - `, + // 'suggestionQuery': ` + // PREFIX text: <http://jena.apache.org/text#> + // PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + // PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + // PREFIX skos: <http://www.w3.org/2004/02/skos/core#> + // PREFIX gs: <http://www.opengis.net/ont/geosparql#> + // SELECT DISTINCT ?label (COUNT(?s) AS ?count) + // WHERE { + // GRAPH <http://ldf.fi/warsa/places/karelian_places> { + // (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . + // } + // ?s skos:prefLabel ?lbl . + // BIND(STR(?lbl) AS ?label) + // } + // GROUP BY ?label + // ORDER BY DESC(MAX(?score)) ?label + // LIMIT 50 + // `, 'simpleSuggestionQuery': ` PREFIX text: <http://jena.apache.org/text#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -73,23 +73,23 @@ module.exports = { 'timePeriod': '1939-1944', 'lang': '', 'endpoint': 'http://ldf.fi/warsa/sparql', - 'suggestionQuery': ` - PREFIX text: <http://jena.apache.org/text#> - PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> - PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - PREFIX skos: <http://www.w3.org/2004/02/skos/core#> - PREFIX gs: <http://www.opengis.net/ont/geosparql#> - SELECT DISTINCT ?label (COUNT(?s) AS ?count) - WHERE { - GRAPH <http://ldf.fi/warsa/places/municipalities> { - (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . - } - ?s skos:prefLabel ?lbl . - BIND(STR(?lbl) AS ?label) - } - GROUP BY ?label - ORDER BY DESC(MAX(?score)) ?label - `, + // 'suggestionQuery': ` + // PREFIX text: <http://jena.apache.org/text#> + // PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + // PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + // PREFIX skos: <http://www.w3.org/2004/02/skos/core#> + // PREFIX gs: <http://www.opengis.net/ont/geosparql#> + // SELECT DISTINCT ?label (COUNT(?s) AS ?count) + // WHERE { + // GRAPH <http://ldf.fi/warsa/places/municipalities> { + // (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . + // } + // ?s skos:prefLabel ?lbl . + // BIND(STR(?lbl) AS ?label) + // } + // GROUP BY ?label + // ORDER BY DESC(MAX(?score)) ?label + // `, 'simpleSuggestionQuery': ` PREFIX text: <http://jena.apache.org/text#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -184,48 +184,61 @@ module.exports = { 'tgn': { // Getty LOD documentation: // http://vocab.getty.edu/queries#Places_by_Type - // http://vocab.getty.edu/doc/#TGN_Place_Types - // http://vocab.getty.edu/doc/queries/#Full_Text_Search_Query // https://groups.google.com/forum/#!topic/gettyvocablod/r4wsSJyne84 // https://confluence.ontotext.com/display/OWLIMv54/OWLIM-SE+Full-text+Search + // http://vocab.getty.edu/queries#Combination_Full-Text_and_Exact_String_Match + // http://vocab.getty.edu/doc/#TGN_Place_Types 'title': 'The Getty Thesaurus of Geographic Names', 'shortTitle': 'TGN', 'timePeriod': 'contemporary', 'endpoint': 'http://vocab.getty.edu/sparql.json', - 'simpleSuggestionQuery': 'SELECT+DISTINCT+?label{?s+a+skos:Concept;+luc:term+"<QUERYTERM>*";+skos:inScheme+tgn:;gvp:prefLabelGVP/xl:literalForm+?lbl+.+BIND(STR(?lbl)+AS+?label)}LIMIT+20', + 'simpleSuggestionQuery': + 'SELECT+DISTINCT+?label+' + + 'WHERE+{' + + '?s+a+skos:Concept;+' + + 'luc:term+"<QUERYTERM>*";+' + + 'skos:inScheme+tgn:;' + + 'gvp:prefLabelGVP/xl:literalForm+?lbl+.' + + '+BIND(STR(?lbl)+AS+?label)' + + 'FILTER+(STRSTARTS(LCASE(?lbl),+"<QUERYTERM>"))' + + '}' + + 'LIMIT+20', 'resultQuery': - 'SELECT+?s+(COALESCE(?labelEn,?labelGVP)+AS+?label)+?typeLabel+?broaderAreaLabel+?source+?lat+?long' + - '{?s+luc:term+"<QUERYTERM>";+' + + 'SELECT+?s+(COALESCE(?labelEn,?labelGVP)+AS+?label)+?typeLabel+?broaderAreaLabel+?source+?lat+?long+' + + 'WHERE+{' + + '?s+luc:term+"<QUERYTERM>";+' + 'skos:inScheme+tgn:;+' + 'gvp:placeTypePreferred+[gvp:prefLabelGVP+[xl:literalForm+?typeLabel;dct:language+gvp_lang:en]];+' + 'gvp:parentStringAbbrev+?broaderAreaLabel+.+' + 'OPTIONAL+{?s+xl:prefLabel+[xl:literalForm+?labelEn;+dct:language+gvp_lang:en]}+' + 'OPTIONAL{?s+gvp:prefLabelGVP+[xl:literalForm?labelGVP]}+' + 'OPTIONAL{?s+foaf:focus+?place+.+?place+wgs:lat+?lat;+wgs:long+?long}+' + - 'BIND("TGN"+AS+?source)+}', + 'FILTER+EXISTS+{?s+xl:prefLabel/gvp:term+?term+.+FILTER+(LCASE(STR(?term))="<QUERYTERM>")}' + + 'BIND("TGN"+AS+?source)+' + + '}', }, 'kotus': { 'title': 'Institute for the Languages of Finland (Kotus) Digital Names archive', 'shortTitle': 'DNA', 'endpoint': 'http://ldf.fi/kotus-digital-names-archive/sparql', //'endpoint': 'http://localhost:3037/ds/sparql', - 'suggestionQuery': ` - PREFIX text: <http://jena.apache.org/text#> - PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> - PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> - PREFIX skos: <http://www.w3.org/2004/02/skos/core#> - PREFIX gs: <http://www.opengis.net/ont/geosparql#> - PREFIX hipla: <http://ldf.fi/schema/hipla/> - SELECT DISTINCT ?label (COUNT(?s) AS ?count) - WHERE { - (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . - ?s hipla:type [] . - ?s skos:prefLabel ?lbl . - BIND(STR(?lbl) AS ?label) - } - ORDER BY DESC(MAX(?score)) ?label - LIMIT 50 - `, + // 'suggestionQuery': ` + // PREFIX text: <http://jena.apache.org/text#> + // PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + // PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> + // PREFIX skos: <http://www.w3.org/2004/02/skos/core#> + // PREFIX gs: <http://www.opengis.net/ont/geosparql#> + // PREFIX hipla: <http://ldf.fi/schema/hipla/> + // SELECT DISTINCT ?label (COUNT(?s) AS ?count) + // WHERE { + // (?s ?score) text:query (skos:prefLabel '<QUERYTERM>*') . + // ?s hipla:type [] . + // ?s skos:prefLabel ?lbl . + // BIND(STR(?lbl) AS ?label) + // } + // ORDER BY DESC(MAX(?score)) ?label + // LIMIT 20 + // `, 'simpleSuggestionQuery': ` PREFIX text: <http://jena.apache.org/text#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> diff --git a/src/server/SparqlApi.js b/src/server/SparqlApi.js index 310a280a..d67fda58 100644 --- a/src/server/SparqlApi.js +++ b/src/server/SparqlApi.js @@ -20,7 +20,6 @@ class SparqlApi { return new Promise((resolve, reject) => { if (this.endpoint === 'http://vocab.getty.edu/sparql.json') { - //const q = 'select*{?s+a+gvp:Facet;skos:inScheme+aat:;gvp:prefLabelGVP/xl:literalForm?label}'; const url = this.endpoint + '?query=' + query; fetch(url) .then(response => { -- GitLab