Some cities aren't instances of city or big city? Odd behaviour of Wikidata

别说谁变了你拦得住时间么 提交于 2019-12-24 20:27:00

问题


While examining the results of the official example query "Continents, countries, regions and capitals" (on https://query.wikidata.org/, limited to Germany for your convenience here: link), I noticed that some capitals of German federal states were missing. For example Wiesbaden as capital of Hesse. I noticed that Wiesbaden is an instance of big city, but not of city (see https://www.wikidata.org/wiki/Q1721), in contrast to some other cities. I was able to alleviate the problem by also including cities that are subclasses of city by changing line 17 to ?city wdt:P31/wdt:P279? wd:Q515.
One of the four cities that are still missing is Magdeburg, the capital of Saxony-Anhalt.
The diagnostic query

SELECT ?cityLabel ?props
WHERE {
  ?city wdt:P31 ?props.
  FILTER(?city = wd:Q1733 || ?city = wd:Q1726).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

shows that Magdeburg is not even an instance of city, although it clearly is according to its Wikidata page https://www.wikidata.org/wiki/Q1733.

I am new to Wikidata and SPARQL. However, this seems wrong to me. What can I do to get all capitals of the german federal states? And what is the reason for this behaviour?


回答1:


These missing statements are not truthy:

SELECT ?statement ?valueLabel ?rank ?best
WHERE {
  wd:Q1733 p:P31 ?statement.
  ?statement ps:P31 ?value .
  ?statement wikibase:rank ?rank .
  OPTIONAL { ?statement a ?best . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Try it!

They are normal-rank statements, but there is a preferred-rank statement.

Truthy statements represent statements that have the best non-deprecated rank for given property. Namely, if there is a preferred statement for property P2, then only preferred statements for P2 will be considered truthy. Otherwise, all normal-rank statements for P2 are considered truthy.

Update

I have decreased the rank of the preferred statement just now. Please test your query again.



来源:https://stackoverflow.com/questions/55314201/my-sparql-only-get-answers-partially-missing-some-answers-unanswered

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!