在SPARQL中查找实体的超类 [英] finding super classes of an entity in SPARQL

查看:212
本文介绍了在SPARQL中查找实体的超类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用维基百科数据创建一个名称实体识别器,我需要获取一个单词的所有超类,以查看该单词属于哪个类别(位置,人类,组织或无).我上网冲浪很多,发现一些页面:

I want to make a Name Entity Recognizer using wikipedia Data, I need to get all the super classes of a word to see in which category (Place, Human, Organization or None) the word is. I surfed the Internet a lot and find some pages like :

当我执行查询时,即使使用页面中提到的单词并尝试其他命名空间,结果仍为找不到匹配的记录". 和:

which when I execute the query results "No matching records found" even with the word mentioned in the page and trying other namespaces. and:

这与我的工作非常相似,但是我也得到了找不到匹配的记录"结果.

which is very similar to my work, but I get the "No matching records found" result too.

我认为这些链接中提到的查询在逻辑上是正确的,但是我不知道为什么它们对我没有任何结果.我还尝试通过这些站点中提到的示例来学习SPARQL:

I think the queries mentioned in these links are logically correct, but I have no idea why they results nothing for me. I also tried to learn SPARQL by examples mentioned in these sites :

  • https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples
  • https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries

我没有找到任何东西可以找到单词的超类.

and I didn't find anything for finding super classes of a word.

有一些我没有得到结果的代码示例:

There are some examples of the codes which I didn't get result:

PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX ns:<http://dbpedia.org/>

SELECT ?subClass ?label WHERE { 
    ?subClass rdfs:subClassOf ns:Albert . 
    ?subClass rdfs:label ?label . }

或:

SELECT * WHERE {
  dbpedia:Albert a ?c1 ; a ?c2 .
  ?c1 rdfs:subClassOf ?c2 .
}

如果您回答我的问题,我非常感谢.

I really appreciate if you answer my question.

感谢进阶

推荐答案

可能您正在寻找类似以下查询的内容:

Probably, you are looking for something like this query:

SELECT DISTINCT ?c WHERE {
  ?Q wdt:P31/wdt:P279? ?c .
  ?Q rdfs:label "Tom Hanks"@en
} 

Wikidata使用其自己的谓词而不是rdf:typerdfs:subClassOf( wdt:P31 wdt:P279 ).

Wikidata uses its own predicates instead of rdf:type and rdfs:subClassOf (wdt:P31 and wdt:P279 respectively).

这篇关于在SPARQL中查找实体的超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆