sparql query on wikidata

落花浮王杯 提交于 2019-12-31 05:23:10

问题


i am very new to sparql and i am trying to run 3 queries on wikidata:

  1. Persons who are not painters and who are students of painters.
  2. Persons who are not painters and who are academic offspring or children of painters (note: an academic offspring of a person P is somebody who is/was a student of P, or a student of a student of P, or .... ).
  3. People who are academic offspring of themselves.

i got stuck on the first one, i tried:

SELECT DISTINCT ?human ?humanLabel WHERE {
  ?human wdt:P31 wd:Q5.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  ?human wikibase:statements ?statementcount.
  ?human wdt:P106 ?profession.
  FILTER(?profession != wd:Q1028181)
  FILTER(?statementcount > 50 )
  ?human wdt:P1066 ?teacher.
  ?teacher wdt:P106 ?tprofession.
  FILTER(?tprofession = wd:Q1028181)
  OPTIONAL {  }

}LIMIT 50

but i think in this line: FILTER(?profession != wd:Q1028181), is not checking all the professions against painter but just the first one, so i get painters that have multiple occupations in the output because is checking just the first occupation against painter, but i want all those occupations checked against painter.

来源:https://stackoverflow.com/questions/58581648/sparql-query-with-wikidata

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