SPARQL DBPedia 编码

SPARQL DBPedia encoding

我 运行 在 DBpedia 上查询,我收到的一些结果显然有错误的编码和显示为问号的字符,例如--

http://dbpedia.org/resource/Bo?aziçi_University

-- 我希望看到的地方 --

http://dbpedia.org/resource/Bo%C4%9Fazi%C3%A7i_University

Here你可以找到实际标题。

您可以在 http://live.dbpedia.org/sparql

处执行我的查询
PREFIX yago: <http://dbpedia.org/class/yago/>
PREFIX schema: <http://schema.org/>
PREFIX dbpedia: <http://dbpedia.org/>

SELECT ?school
WHERE
{
    { ?school rdf:type   schema:EducationalOrganization . }
    UNION
    { ?school rdf:type   yago:EducationalInstitution108276342 . }
    UNION
    { ?school rdf:type   yago:College108278169 . }
    UNION
    { ?school dbpedia:type   dbr:Public_university . }
}

我做错了什么吗?我是否必须对查询进行任何添加才能获得正确的结果?是不是数据相关(基本上是数据错了没办法)?

我不认为你做错了什么。我认为您看到的结果与 Boğaziçi University 相同,后者也显示在结果中。这可能只是数据中的一些噪音。如果您询问名称中带有文字问号的实体,您会看到一堆。这是您的查询的简化版本(不使用 union),它仅包括那些在其 URI 中带有 ? 的实体:

SELECT DISTINCT ?school WHERE
{
  values ?type { schema:EducationalOrganization
                 yago:EducationalInstitution108276342
                 yago:College108278169
                 dbr:Public_university }
  values ?hasType { rdf:type dbpedia:type }
  ?school ?hasType ?type .

  filter(contains(str(?school), "?"))
}

SPARQL results

您可以反转该过滤器并简单地排除这些结果,我认为您最终会得到想要的结果:

SELECT DISTINCT ?school WHERE
{
  values ?type { schema:EducationalOrganization
                 yago:EducationalInstitution108276342
                 yago:College108278169
                 dbr:Public_university }
  values ?hasType { rdf:type dbpedia:type }
  ?school ?hasType ?type .

  filter(!contains(str(?school), "?"))
}

SPARQL results