dbpedia中的自由文本搜索

时间:2018-06-29 18:21:43

标签: sparql dbpedia virtuoso

我想对dbpedia使用自由文本搜索,我正在尝试在W3C网站上找到的查询:https://www.w3.org/2009/Talks/0615-qbe/

如果我在不带bif:前缀的情况下尝试查询,则会得到查询下方显示的错误:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
# PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
  ?country rdfs:label ?lbl .
  FILTER(bif:contains(?lbl, "Republic")) .
  ?country a type:Country108544813 ;
      prop:establishedDate ?est .
  FILTER(?est < "1920-01-01"^^xsd:date) .
}

错误:第9行,解析错误:“ bif”的名称空间映射未定义        当扩展QName“ bif:contains”时。 [条件类型:sparql-lexer-error-namespace-mapping-not-defined]

好:这很有意义,您确实需要定义名称空间。因此,让我使用在Virtuoso网站(及其他地方)上找到的bif:前缀再次进行相同的查询

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>        
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
  ?country rdfs:label ?lbl .
  FILTER(bif:contains(?lbl, "Republic")) .
  ?country a type:Country108544813 ;
      prop:establishedDate ?est .
  FILTER(?est < "1920-01-01"^^xsd:date) .
}

现在我得到另一个错误:看来bif:名称空间是Virtuoso的受保护名称

enter image description here

所以看来我不能忍受bif:或没有:bif。有没有人看过这个错误?谢谢。

顺便说一句:我真的不太在乎bif:我真正想要的是对dbpedia进行自由文本查询。因此,欢迎您选择其他方法。是的:关于此有较早的问题,但请注意,每个答案中也都包含bif:。

后来添加了:所以为了确保我将bif:更改为bof:,现在我得到一个新错误,该错误表明不再包含有效操作符。见下文。所以无论如何:我想从这里开始我唯一关心的是:如何对dbpedia执行自由文本查询:-)

enter image description here

1 个答案:

答案 0 :(得分:0)

bif:是Virtuoso内置的,用于“内置功能”。

您正在经历某种SPARQL预解析器,而不是直接针对SPARQL端点,因此您确实需要在查询中定义前缀。如果您只是-

,大多数此类预准备者将做正确的事情
PREFIX  bif:  <bif:>

或者,您可以使用bif:contains函数来更改查询-

FILTER(bif:contains(?lbl, "Republic"))

-使用SPARQL正则表达式-

FILTER regex(?lbl, "Republic")