Skip to content

Commit

Permalink
Updated reconciliation sparql query
Browse files Browse the repository at this point in the history
  • Loading branch information
sahalali committed Oct 24, 2024
1 parent 0609cf4 commit 8ecc0aa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 85 deletions.
134 changes: 50 additions & 84 deletions src/constant/recon-queries.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,48 @@ PREFIX ado: <http://kg.artsdata.ca/ontology/>
PREFIX onto: <http://www.ontotext.com/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?entity
?score
?nameEn
?nameFr
?name
?description
?descriptionEn
?descriptionFr
?type_additional
?type_label
WHERE{
?entity a ?type_additional.
#TYPE
OPTIONAL { ?type_additional rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") }
OPTIONAL { ?type_additional rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") }
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
{SELECT DISTINCT
?entity
?score
(SAMPLE(?name_en) as ?nameEn)
(SAMPLE(?name_fr) as ?nameFr)
(SAMPLE(?name_no) as ?name)
(SAMPLE(?description_no) as ?description)
(SAMPLE(?description_en) as ?descriptionEn)
(SAMPLE(?description_fr) as ?descriptionFr)
SELECT DISTINCT
?entity
?score
(SAMPLE(?name_en) as ?nameEn)
(SAMPLE(?name_fr) as ?nameFr)
(SAMPLE(?name_no) as ?name)
(SAMPLE(?description_no) as ?description)
(SAMPLE(?description_en) as ?descriptionEn)
(SAMPLE(?description_fr) as ?descriptionFr)
?type_label
WHERE
{
QUERY_PLACE_HOLDER
TYPE_PLACE_HOLDER
QUERY_PLACE_HOLDER
TYPE_PLACE_HOLDER
?search a luc-index:INDEX_PLACE_HOLDER ;
QUERY_FILTER_PLACE_HOLDER
luc:entities ?entity .
PROPERTY_PLACE_HOLDER
?search a luc-index:INDEX_PLACE_HOLDER ;
QUERY_FILTER_PLACE_HOLDER
luc:entities ?entity .
PROPERTY_PLACE_HOLDER
FILTER (CONTAINS(STR(?entity),"kg.artsdata.ca/resource/"))
FILTER (CONTAINS(STR(?entity),"kg.artsdata.ca/resource/"))
?entity luc:score ?score;
# a ?type_additional.
?entity luc:score ?score;
#NAME
#NAME
OPTIONAL { ?entity schema:name ?name_en. FILTER( LANG(?name_en) = "en") }
OPTIONAL { ?entity schema:name ?name_fr. FILTER( LANG(?name_fr) = "fr")}
OPTIONAL { ?entity schema:name ?name_no. FILTER ( LANG(?name_no) = "")}
#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)
#TYPE
?entity a ?type_additional.
OPTIONAL { ?type_additional rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") }
OPTIONAL { ?type_additional rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") }
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
#DISAMBIGUATING DESCRIPTION
OPTIONAL { ?entity schema:disambiguatingDescription ?description_en. FILTER( LANG(?description_en) = "en") }
OPTIONAL { ?entity schema:disambiguatingDescription ?description_fr. FILTER( LANG(?description_fr) = "fr")}
OPTIONAL { ?entity schema:disambiguatingDescription ?description_no. FILTER ( LANG(?description_no) = "")}
} group by ?entity ?score ?type_label ?type
LIMIT_PLACE_HOLDER }
}
#DISAMBIGUATING DESCRIPTION
OPTIONAL { ?entity schema:disambiguatingDescription ?description_en. FILTER( LANG(?description_en) = "en") }
OPTIONAL { ?entity schema:disambiguatingDescription ?description_fr. FILTER( LANG(?description_fr) = "fr")}
OPTIONAL { ?entity schema:disambiguatingDescription ?description_no. FILTER ( LANG(?description_no) = "")}
} group by ?entity ?score ?type ?type_label
LIMIT_PLACE_HOLDER
`,

RECONCILIATION_QUERY_BY_URI: `
Expand All @@ -78,53 +62,35 @@ PREFIX ado: <http://kg.artsdata.ca/ontology/>
PREFIX onto: <http://www.ontotext.com/>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?entity
?score
?nameEn
?nameFr
?name
?description
?descriptionEn
?descriptionFr
?type_additional
?type_label
WHERE{
?entity a ?type_additional.
#TYPE
OPTIONAL { ?type_additional rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") }
OPTIONAL { ?type_additional rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") }
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
{SELECT DISTINCT
?entity
?score
(SAMPLE(?name_en) as ?nameEn)
(SAMPLE(?name_fr) as ?nameFr)
(SAMPLE(?name_no) as ?name)
(SAMPLE(?description_no) as ?description)
(SAMPLE(?description_en) as ?descriptionEn)
(SAMPLE(?description_fr) as ?descriptionFr)
SELECT DISTINCT
?entity
?score
(SAMPLE(?name_en) as ?nameEn)
(SAMPLE(?name_fr) as ?nameFr)
(SAMPLE(?name_no) as ?name)
(SAMPLE(?description_no) as ?description)
(SAMPLE(?description_en) as ?descriptionEn)
(SAMPLE(?description_fr) as ?descriptionFr)
?type_label
WHERE
{
BIND(URI_PLACEHOLDER as ?entity)
#?entity a ?type.
#NAME
OPTIONAL { ?entity schema:name ?name_en. FILTER( LANG(?name_en) = "en") }
OPTIONAL { ?entity schema:name ?name_fr. FILTER( LANG(?name_fr) = "fr")}
OPTIONAL { ?entity schema:name ?name_no. FILTER ( LANG(?name_no) = "")}
#TYPE
?entity a ?type_additional.
OPTIONAL { ?type_additional rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") }
OPTIONAL { ?type_additional rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") }
BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
#TYPE
#OPTIONAL { ?type_additional rdfs:label ?type_label_raw filter(lang(?type_label_raw) = "") }
# OPTIONAL { ?type_additional rdfs:label ?type_label_en filter(lang(?type_label_en) = "en") }
#BIND(COALESCE(?type_label_en, ?type_label_raw, "") as ?type_label)
#DISAMBIGUATING DESCRIPTION
#DISAMBIGUATING DESCRIPTION
OPTIONAL { ?entity schema:disambiguatingDescription ?description_en. FILTER( LANG(?description_en) = "en") }
OPTIONAL { ?entity schema:disambiguatingDescription ?description_fr. FILTER( LANG(?description_fr) = "fr")}
OPTIONAL { ?entity schema:disambiguatingDescription ?description_no. FILTER ( LANG(?description_no) = "")}
} group by ?entity ?score ?type_label ?type
LIMIT_PLACE_HOLDER }
}
} group by ?entity ?score ?type ?type_label
LIMIT_PLACE_HOLDER
`
};
2 changes: 1 addition & 1 deletion src/service/recon/recon.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe("Recon Service tests", () => {
}
],
expectedName: "Canadian Stage - Berkeley Street Theatre",
expectedCount: 2,
expectedCount: 1,
duplicateCheck: true
}, {
description: "It should match names with single neutral quote",
Expand Down

0 comments on commit 8ecc0aa

Please sign in to comment.