Anonymous

Main Page: Difference between revisions

From geokb
2,416 bytes added ,  3 months ago
Added section on federated queries for foreign representations of entities
No edit summary
(Added section on federated queries for foreign representations of entities)
Line 424: Line 424:
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
}
</sparql>
== Federated queries and "same as" links ==
One of the things we are working on in the GeoKB is the establishment of as many relationships as possible to other sources, including formal ontologies (for classes and properties) as well as similar knowledge bases. The latter includes Wikidata with a goal of connecting the "Global Knowledge Commons" with further information and details about items that we have some ownership of from the USGS. We build these linkages using the [[Property:P84|same as]] property, pointing to a persistent resolvable identifier in URL form in the foreign system. We are following a loose definition of "same as" here that is somewhere shy of exact match. It essentially means that we consider an item in the GeoKB to be representing the same thing that the linked entity also represents, accepting that neither our representation nor the foreign representation is necessarily complete or completely accurate. However, taken together they help to make up a more complete and useful representation.
Not all same as linkages are actionable in the same way. If the foreign resource is also accessible via a SPARQL end point (e.g., Wikidata), then we can build a federated query that is able to pull additional details about entities from the foreign source. Here's an example that uses the GeoKB representation of US States containing same as relationships with Wikidata representations to pull coordinate locations and capital cities from Wikidata.
<sparql tryit="1">
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX geokbe: <https://geokb.wikibase.cloud/entity/>
PREFIX geokbp: <https://geokb.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?fips_alpha ?same_as
?coordinateLocation ?capital_city ?capital_cityLabel
WHERE {
  ?item geokbp:P13 ?fips_alpha ;
        geokbp:P84 ?same_as .
  FILTER (CONTAINS(STR(?same_as), "wikidata.org")) # Need to filter to same as linkages from specific source
  SERVICE <https://query.wikidata.org/sparql> {
?same_as wdt:P625 ?coordinateLocation ;
            wdt:P36 ?capital_city .
    ?capital_city rdfs:label ?capital_cityLabel . # Need to get labels via rdfs:label query
    FILTER(LANG(?capital_cityLabel) = "en") # and filter to English language
  }     
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } # Acts on local query results
}
LIMIT 100
</sparql>
</sparql>