Skip to content

Commit

Permalink
UPDATED SPARQL QUERY TO GET RID OF DUPLICATES IN THE RESULT
Browse files Browse the repository at this point in the history
  • Loading branch information
sahalali committed May 8, 2024
1 parent c2642a3 commit bb8f8bd
Showing 1 changed file with 44 additions and 11 deletions.
55 changes: 44 additions & 11 deletions src/constant/recon-queries.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,65 @@ PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ado: <http://kg.artsdata.ca/ontology/>
SELECT
SELECT DISTINCT
?entity
?score
?name
(sample(?disambiguatingDescriptions) as ?disambiguatingDescription)
?disambiguatingDescription
?type
?typeLabel
?typeLabel
WHERE
{
values ?query { "QUERY_PLACE_HOLDER" }
values ?query { "QUERY_PLACE_HOLDER" }
values ?type { TYPE_PLACE_HOLDER }
?search a luc-index:INDEX_PLACE_HOLDER ;
?search a luc-index:place-index ;
luc:query ?query ;
luc:entities ?entity .
#FILTER (STRSTARTS(STR(?entity),"http://kg.artsdata.ca/resource/K" ))
FILTER (CONTAINS(STR(?entity),"kg.artsdata.ca/resource/"))
?entity luc:score ?score.
?entity rdfs:label ?name.
OPTIONAL { ?originalUri schema:disambiguatingDescription ?disambiguatingDescriptions.}
OPTIONAL { ?type rdfs:label ?type_label_raw filter(lang(?type_label_raw) IN ("", "en" ))
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?typeLabel)
#NAME
OPTIONAL {
?entity rdfs:label ?name_in_english.
FILTER( LANG(?name_in_english) = "en")
}
OPTIONAL {
?entity rdfs:label ?name_in_french.
FILTER( LANG(?name_in_french) = "fr")
}
OPTIONAL {
?entity rdfs:label ?name_without_language.
FILTER ( LANG(?name_without_language) = "")
}
BIND (COALESCE(?name_in_english,?name_in_french, ?name_without_language) as ?name)
# DISAMBIGUATING DESCRIPTION
OPTIONAL {
?entity schema:disambiguatingDescription ?disambiguatingDescription_same_language .
FILTER (LANG(?name) = LANG(?disambiguatingDescription_same_language))
}
}GROUP BY ?entity ?score ?name ?type ?typeLabel
OPTIONAL {
?entity schema:disambiguatingDescription ?disambiguatingDescription_another_language .
FILTER (LANG(?name) != LANG(?disambiguatingDescription_another_language))
}
BIND (COALESCE(?disambiguatingDescription_same_language,?disambiguatingDescription_another_language) as ?disambiguatingDescription)
#TYPE
OPTIONAL {
?type rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "")
}
OPTIONAL {
?type rdfs:label ?type_label_en filter(lang(?type_label_en) = "en")
}
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
} GROUP BY ?entity ?score ?name ?type ?typeLabel ?disambiguatingDescription
LIMIT 5
`

};

0 comments on commit bb8f8bd

Please sign in to comment.