Skip to content
Snippets Groups Projects
Commit 6c0c283c authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Define the order of results in the component that renders the results

parent 0558d0b9
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ module.exports = {
{
SELECT DISTINCT ?s {
GRAPH <http://ldf.fi/warsa/places/karelian_places> {
(?s ?score) text:query (skos:prefLabel '<QUERYTERM>') .
?s text:query (skos:prefLabel '<QUERYTERM>') .
}
}
}
......@@ -65,7 +65,6 @@ module.exports = {
FILTER(LANGMATCHES(LANG(?typeLabel), 'fi'))
FILTER(LANGMATCHES(LANG(?broaderAreaLabel), 'fi'))
}
ORDER BY ?score
`,
},
'warsa_municipalities': {
......@@ -118,7 +117,7 @@ module.exports = {
{
SELECT DISTINCT ?s {
GRAPH <http://ldf.fi/warsa/places/municipalities> {
(?s ?score) text:query (skos:prefLabel '<QUERYTERM>') .
?s text:query (skos:prefLabel '<QUERYTERM>') .
}
}
}
......@@ -134,7 +133,6 @@ module.exports = {
FILTER(LANGMATCHES(LANG(?typeLabel), 'fi'))
FILTER(LANGMATCHES(LANG(?broaderAreaLabel), 'fi'))
}
ORDER BY ?score
`,
},
'pnr': {
......@@ -190,12 +188,14 @@ module.exports = {
PREFIX wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT *
WHERE {
(?s ?score) text:query (skos:prefLabel '<QUERYTERM>') .
?s text:query (skos:prefLabel '<QUERYTERM>') .
?s a hipla:Place .
?s skos:prefLabel ?label .
?s hipla:municipality ?broaderAreaLabel .
OPTIONAL { ?s hipla:type ?typeLabel . }
BIND("DNA" AS ?source)
BIND("undefined" AS ?missingValue)
OPTIONAL { ?s hipla:type ?tLbl . }
BIND(COALESCE(?tLbl, ?missingValue) as ?typeLabel)
OPTIONAL {
?s wgs84:lat ?lat .
?s wgs84:long ?long .
......@@ -204,7 +204,6 @@ module.exports = {
#FILTER(LANGMATCHES(LANG(?typeLabel), 'fi'))
#FILTER(LANGMATCHES(LANG(?broaderAreaLabel), 'fi'))
}
ORDER BY ?score
`,
},
};
......@@ -14,7 +14,7 @@ export const groupBy = (sparqlBindings, group, simplify) => Object.values(_.redu
result[group] = value.value;
} else {
if (simplify) {
result[key] = value.value;
result[key] = capitalizeFirstLetter(value.value);
} else {
const oldVal = result[key];
// add new value if it doesn't already exist
......@@ -45,7 +45,12 @@ export const mergeSimpleSuggestions = (suggestions) => {
export const mergeResults = (results) => {
// SPARQL query defines the ordering of results of one dataset.
// Return all merged results subsequentially.
//console.log(_.flatten(results))
return _.flatten(results);
};
const capitalizeFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
export const mapResults = (results) => groupBy(results, 's', true);
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