Anonymous

Item talk:Q50862: Difference between revisions

From geokb
No edit summary
Line 47: Line 47:


== All USGS Organizations ==
== All USGS Organizations ==
The GeoKB can prove a useful tool in reconciling USGS organization names to other identifiers. Though non-persistent and unstable through time, URLs for organizations could prove useful in some cases and are included in the GeoKB as reference URL claims (P31). The GeoKB can be used as a reconciliation service for something like a spreadsheet of records processed through OpenRefine. The following query will return all USGS organizations, including alternate labels (which includes things like acronyms), in a format that can be suitable for lookup and name resolution purposes.
The GeoKB can prove a useful tool in reconciling USGS organization names to other identifiers. Though non-persistent and unstable through time, URLs for organizations could prove useful in some cases and are included in the GeoKB as reference URL claims (P31). The GeoKB can be used as a reconciliation service for something like a spreadsheet of records processed through OpenRefine. The following query will return all USGS organizations, including alternate labels (which includes things like acronyms), in a format that can be suitable for lookup and name resolution purposes. Since some organizations have multiple URLs listed for official website, these are grouped into a list.


<sparql tryit=1>
<sparql tryit=1>
Line 53: Line 53:
PREFIX wdt: <https://geokb.wikibase.cloud/prop/direct/>
PREFIX wdt: <https://geokb.wikibase.cloud/prop/direct/>


SELECT ?item ?itemLabel ?item_alt_label ?instance_ofLabel ?url
SELECT ?item ?itemLabel ?item_alt_label ?instance_ofLabel  
(GROUP_CONCAT(?url; separator=",") AS ?urls)
WHERE {
WHERE {
   ?org_types wdt:P2 wd:Q50862 . # Gets subclasses of USGS organization
   ?org_types wdt:P2 wd:Q50862 . # Gets subclasses of USGS organization
   ?item wdt:P1 ?org_types . # Gets items in those classes
   ?item wdt:P1 ?org_types ; # Gets items in those classes
  ?item wdt:P1 ?instance_of . # Gets the individual instance of classification
        wdt:P1 ?instance_of . # Gets the individual instance of classification
   OPTIONAL {
   OPTIONAL {
     ?item skos:altLabel ?item_alt_label . # Retrieves alternate labels into separate rows
     ?item skos:altLabel ?item_alt_label . # Retrieves alternate labels into separate rows
Line 63: Line 64:
   }
   }
   OPTIONAL {
   OPTIONAL {
     ?item wdt:P31 ?url . # Get all reference URLs when available
     ?item wdt:P145 ?url . # Get all reference URLs when available
   }
   }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
}
GROUP BY ?item ?itemLabel ?item_alt_label ?instance_ofLabel
</sparql>
</sparql>