Skip to content
Snippets Groups Projects
Commit be70f876 authored by esikkala's avatar esikkala
Browse files

Add tgn dataset, tgn endpoint not working with current post requests

parent a738c675
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -16,25 +16,31 @@ export const INITIAL_STATE = {
'title': 'Institute for the Languages of Finland (Kotus) Digital Names archive',
'shortTitle': 'DNA',
'timePeriod': '1900s',
'selected': true
'selected': false
},
'pnr': {
'title': 'Finnish Geographic Names Registry',
'shortTitle': 'FGN',
'timePeriod': 'contemporary',
'selected': false
},
'tgn': {
'title': 'The Getty Thesaurus of Geographic Names',
'shortTitle': 'TGN',
'timePeriod': '?',
'selected': true
},
'warsa_karelian_places': {
'title': 'Karelian map names',
'shortTitle': 'KMN',
'timePeriod': '1922-1944',
'selected': true
'selected': false
},
'warsa_municipalities': {
'title': 'Finnish WW2 municipalities',
'shortTitle': 'FWM',
'timePeriod': '1939-1944',
'selected': true
'selected': false
},
},
suggestions: [],
......
......@@ -31,7 +31,7 @@ module.exports = {
SELECT DISTINCT ?label
WHERE {
GRAPH <http://ldf.fi/warsa/places/karelian_places> {
?s text:query (skos:prefLabel '<QUERYTERM>*' 10000) .
?s text:query (skos:prefLabel '<QUERYTERM>*' 50) .
}
?s skos:prefLabel ?lbl .
BIND(STR(?lbl) AS ?label)
......@@ -99,7 +99,7 @@ module.exports = {
SELECT DISTINCT ?label
WHERE {
GRAPH <http://ldf.fi/warsa/places/municipalities> {
?s text:query (skos:prefLabel '<QUERYTERM>*' 10000) .
?s text:query (skos:prefLabel '<QUERYTERM>*' 50) .
}
?s skos:prefLabel ?lbl .
BIND(STR(?lbl) AS ?label)
......@@ -149,7 +149,7 @@ module.exports = {
PREFIX sf: <http://ldf.fi/functions#>
SELECT DISTINCT ?label
WHERE {
?s text:query (skos:prefLabel '<QUERYTERM>*' 10000) .
?s text:query (skos:prefLabel '<QUERYTERM>*' 50) .
?s sf:preferredLanguageLiteral (skos:prefLabel 'fi' '' ?lbl) .
BIND(STR(?lbl) AS ?label)
}
......@@ -181,6 +181,55 @@ module.exports = {
}
`,
},
'tgn': {
'title': 'The Getty Thesaurus of Geographic Names',
'shortTitle': 'TGN',
'timePeriod': 'contemporary',
'endpoint': 'http://vocab.getty.edu/sparql.json',
'simpleSuggestionQuery': `
PREFIX gvp: <http://vocab.getty.edu/ontology#>
PREFIX luc: <http://www.ontotext.com/owlim/lucene#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX xl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT ?label
WHERE {
?s skos:inScheme <http://vocab.getty.edu/tgn/> .
?s luc:term '<QUERYTERM>*' .
?s gvp:prefLabelGVP [xl:literalForm ?lbl]
BIND(STR(?lbl) AS ?label)
}
LIMIT 20
`,
'resultQuery': `
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 sf: <http://ldf.fi/functions#>
PREFIX wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX crm: <http://www.cidoc-crm.org/cidoc-crm/>
SELECT DISTINCT *
WHERE {
?s text:query (skos:prefLabel '<QUERYTERM>') .
?s sf:preferredLanguageLiteral (skos:prefLabel 'fi' '' ?label) .
?s a ?type .
?type sf:preferredLanguageLiteral (skos:prefLabel 'fi' '' ?typeLabel) .
?s wgs84:lat ?lat .
?s wgs84:long ?long .
OPTIONAL {
?s crm:P89_falls_within ?municipality .
?municipality a ?munType .
?municipality sf:preferredLanguageLiteral (skos:prefLabel 'fi' '' ?broaderAreaLabel) .
FILTER (?munType != <http://ldf.fi/pnr-schema#SubRegion>)
}
BIND("PNR" AS ?source)
}
`,
},
'kotus': {
'title': 'Institute for the Languages of Finland (Kotus) Digital Names archive',
'shortTitle': 'DNA',
......@@ -212,7 +261,7 @@ module.exports = {
PREFIX hipla: <http://ldf.fi/schema/hipla/>
SELECT DISTINCT ?label
WHERE {
?s text:query (skos:prefLabel '<QUERYTERM>*' 10000) .
?s text:query (skos:prefLabel '<QUERYTERM>*' 50) .
?s hipla:type [] .
?s skos:prefLabel ?lbl .
BIND(STR(?lbl) AS ?label)
......
import request from 'superagent';
import fetch from 'node-fetch';
const defaultSelectHeaders = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/sparql-results+json'
'Accept': 'application/sparql-results+json; charset=utf-8'
};
const defaultConstructHeaders = {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'text/turtle'
};
const test = {
'head' : {
'vars' : [ 'label' ]
},
'results' : {
'bindings' :
[ {
'label' : {
'type' : 'literal',
'value' : 'test'
}
},
{
'label' : {
'type' : 'literal',
'value' : 'test2'
}
}
]
}
};
class SparqlApi {
constructor({ endpoint }) {
......@@ -17,11 +40,41 @@ class SparqlApi {
query(query, { headers }) {
return new Promise((resolve, reject) => {
//
// fetch('http://vocab.getty.edu/sparql.json?query=select*{?f+a+gvp:Facet;skos:inScheme+aat:;gvp:prefLabelGVP/xl:literalForm?l}')
// .then(response => { return response.json();})
// .then(responseData => {console.log(responseData); return responseData;})
// .catch(error => console.log('error is', error));
//
// fetch('http://vocab.getty.edu/sparql.json',
// { method: 'POST',
// body: 'query=' + query,
// })
// .then(res => {
// return res.json()
// //res.text();
// })
// .then(data => console.log('data is', data))
// .catch(error => console.log('error is', error));
// The res.text property contains the unparsed response body string. This
// property is always present for the client API, and only when the mime type
// matches "text/", "/json", or "x-www-form-urlencoded" by default for node.
// The reasoning is to conserve memory, as buffering text of
// large bodies such as multipart files or images is extremely inefficient.
// To force buffering see the "Buffering responses" section
request.post(this.endpoint)
.send({ query })
.set(headers)
.end((err, res) => {
//console.log(res.headers);
//console.log(res.body);
//console.log(res.text);
//console.log(res.req.rawHeaders)
if (err || !res.ok) return reject(err);
//return(resolve(JSON.stringify(test)));
return resolve(res.text);
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment