Service Factforge sparql端点使用的限制图

Service Factforge sparql端点使用的限制图,service,rdf,sparql,Service,Rdf,Sparql,用于运行此查询 prefix oxprop: <http://ophileon.com/ox/property#> prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix owl: <http://www.w3.org/2002/07/owl#> prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#> prefix g

用于运行此查询

prefix oxprop: <http://ophileon.com/ox/property#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:  <http://www.w3.org/2002/07/owl#>
prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix gn: <http://www.geonames.org/ontology#>

select *

from <http://www.ophileon.com/ox/poi.rdf>

where
{
   ?poi rdfs:label ?poiname.
   ?poi owl:sameAs ?geonameuri.
   SERVICE <http://factforge.net/sparql>{
   ?geonameuri gn:population ?population.
   }
   FILTER(langMatches(lang(?poiname), "EN")).
}
返回

-------------------------------------------------------------------------------------------------------
| poi                            | poiname          | geonameuri                         | population |
=======================================================================================================
| <http://ophileon.com/ox/poi/2> | "Wageningen"@en  | <http://sws.geonames.org/2745088/> | "35433"    |
| <http://ophileon.com/ox/poi/3> | "Netherlands"@en | <http://sws.geonames.org/2750405/> | "16645000" |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "767457"   |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "741636"   |
-------------------------------------------------------------------------------------------------------

i、 e.具有人口的多个值。显然来自factforge查询的不同图表。有没有一种方法可以限制factforge或将其优先化,例如地理名称图?顺便说一句,geonames不提供开放的SPARQL端点,这就是我使用Factforge的原因。

让我们从稍微更改查询开始。让我们强迫你说出你的名字Amsterdam@en,因此我们只能得到有问题的结果:

prefix oxprop: <http://ophileon.com/ox/property#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:  <http://www.w3.org/2002/07/owl#>
prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix gn: <http://www.geonames.org/ontology#>

select *

from <http://www.ophileon.com/ox/poi.rdf>

where
{
   values ?poiname { "Amsterdam"@en }
   ?poi rdfs:label ?poiname.
   ?poi owl:sameAs ?geonameuri.
   SERVICE <http://factforge.net/sparql> {
     ?geonameuri gn:population ?population.
   }
   FILTER(langMatches(lang(?poiname), "EN")).
}

oke@JoshuaTaylor再次感谢您详尽的回答。在我完全掌握它的深度之前,我必须先研究一下。要花我几天的时间,因为我要去乡下。
   SERVICE <http://factforge.net/sparql> {
     graph ?g { ?geonameuri gn:population ?population. }
   }
----------------------------------------------------------------------------------------------------------------------------
| poiname        | poi                            | geonameuri                         | population | g                    |
============================================================================================================================
| "Amsterdam"@en | <http://ophileon.com/ox/poi/1> | <http://sws.geonames.org/2759794/> | "741636"   | <http://nytimes.com> |
----------------------------------------------------------------------------------------------------------------------------
prefix oxprop: <http://ophileon.com/ox/property#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:  <http://www.w3.org/2002/07/owl#>
prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix gn: <http://www.geonames.org/ontology#>

select *

from <http://www.ophileon.com/ox/poi.rdf>

where
{
   ?poi rdfs:label ?poiname.
   ?poi owl:sameAs ?geonameuri.
   SERVICE <http://factforge.net/sparql>{
    graph ?g { ?geonameuri gn:population ?population. }
   }
   FILTER(langMatches(lang(?poiname), "EN")).
}
------------------------------------------------------------------------------------------------------------------------------
| poi                            | poiname          | geonameuri                         | population | g                    |
==============================================================================================================================
| <http://ophileon.com/ox/poi/3> | "Netherlands"@en | <http://sws.geonames.org/2750405/> | "16645000" | <http://nytimes.com> |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "741636"   | <http://nytimes.com> |
------------------------------------------------------------------------------------------------------------------------------
{ graph ?g { ?geonameuri gn:population ?population. } }
union
{ ?geonameuri gn:population ?population. }
------------------------------------------------------------------------------------------------------------------------------
| poi                            | poiname          | geonameuri                         | population | g                    |
==============================================================================================================================
| <http://ophileon.com/ox/poi/2> | "Wageningen"@en  | <http://sws.geonames.org/2745088/> | "35433"    |                      |
| <http://ophileon.com/ox/poi/3> | "Netherlands"@en | <http://sws.geonames.org/2750405/> | "16645000" | <http://nytimes.com> |
| <http://ophileon.com/ox/poi/3> | "Netherlands"@en | <http://sws.geonames.org/2750405/> | "16645000" |                      |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "741636"   | <http://nytimes.com> |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "767457"   |                      |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "741636"   |                      |
------------------------------------------------------------------------------------------------------------------------------
prefix oxprop: <http://ophileon.com/ox/property#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:  <http://www.w3.org/2002/07/owl#>
prefix wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
prefix gn: <http://www.geonames.org/ontology#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

select
  ?poi
  ?poiname
  ?geonameuri
  (min(?population) as ?minPopulation)
  (max(?population) as ?maxPopulation)
  (group_concat(?population;separator=' ') as ?allPopulations)
  (avg(xsd:integer(?population)) as ?avgPopulation)
  (sample(?population) as ?somePopulation)

from <http://www.ophileon.com/ox/poi.rdf>

where
{
   ?poi rdfs:label ?poiname.
   ?poi owl:sameAs ?geonameuri.
   SERVICE <http://factforge.net/sparql> {
     ?geonameuri gn:population ?population.
   }
   FILTER(langMatches(lang(?poiname), "EN")).
}
group by ?poi ?poiname ?geonameuri
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| poi                            | poiname          | geonameuri                         | minPopulation | maxPopulation | allPopulations  | avgPopulation | somePopulation |
=============================================================================================================================================================================
| <http://ophileon.com/ox/poi/2> | "Wageningen"@en  | <http://sws.geonames.org/2745088/> | "35433"       | "35433"       | "35433"         | 35433.0       | "35433"        |
| <http://ophileon.com/ox/poi/3> | "Netherlands"@en | <http://sws.geonames.org/2750405/> | "16645000"    | "16645000"    | "16645000"      | 16645000.0    | "16645000"     |
| <http://ophileon.com/ox/poi/1> | "Amsterdam"@en   | <http://sws.geonames.org/2759794/> | "741636"      | "767457"      | "767457 741636" | 754546.5      | "767457"       |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------