Filter by language only if the object is a literal

淺唱寂寞╮ 提交于 2019-12-04 06:12:35

You could use the isLiteral function to apply the language restriction only to objects that are literals.

x implies y can be expressed with SPARQL operators as !x || y, so you could write your query like this:

SELECT DISTINCT
  ?predicate
  ?object
  ?label
WHERE {
  VALUES        ?subject     { <http://dbpedia.org/resource/Hercules_(1997_film)> }
  ?subject      ?predicate   ?object .
  ?predicate    rdfs:label   ?label .
  FILTER(!isLiteral(?object) || langMatches(lang(?object), "EN"))
}
LIMIT 100

As for your secondary question, the description for language tags from the RDF concepts and abstracts only mentions language tags to appear as a part of plain literals. Likewise, the grammar in the SPARQL 1.1 specification uses the LANGTAG nonterminal only in the RDFLiteral production as an exclusive alternative instead of a datatype IRI.

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