问题描述
我对这些主题很陌生。我阅读了sparql文件,并尝试获取特定人的性别。举例来说,我要 Larry_Page性别。我能够获取lary_page的所有属性(基于以下页面:),但它没有任何名为性别的属性。那么我怎样才能得到一个特定人的性别……?谁能告诉我答案。
I am very new to these topics. I read the sparql documents and I am trying to get a gender of a particular person. Say for example I want Larry_Page gender. I was able to getting all the properties of lary_page (Based on the following page: http://dbpedia.org/resource/Larry_Page
) but it doesn't have any property called Gender. So how can I get the gender of a particular person...??? Can any one tell me the answer please.
推荐答案
DBpedia并不是特别完整的数据集。对于您正在寻找的人,很可能根本没有定义任何性别属性-与。
DBpedia is not a particularly complete dataset. It is well possible that for the person you are looking at, there simply is no gender property of any kind defined - similar to the situation outlined in the answer in this thread.
即使存在,也请记住,它可以由多种属性和值表示,因此您必须检查所有属性和值,以至少在以下位置使用数据:它被定义。快速检查至少会显示以下属性,这些属性可以存储您感兴趣的信息:
Even if there is, keep in mind that it can be expressed by a variety of properties and values, so you would have to check all of them to at least use the data where it is defined. A quick check shows me at least the following properties that may store the information you are interested in:
http://dbpedia.org/ontology/gender
http://dbpedia.org/ontology/sex
http://xmlns.com/foaf/0.1/gender
请注意,其中一些可能链接到其他资源,例如或,而其他人只会包含诸如 male
或 female
之类的字符串(FOAF规范明确指出
Note that some of these may link to other resources such as Male
or Female
, whereas others will simply contain strings such as male
or female
(the FOAF specification explicitly says
)。
例如,以下查询返回 Scheherazade :
SELECT ?gl
WHERE {
dbpedia:Scheherazade dbpedia-owl:gender ?g.
?g rdfs:label ?gl.
FILTER(lang(?gl) = "en").
}
同样,以下查询列出了一些人员的姓名和性别:
Likewise, the following query lists the name and gender of a number of persons:
SELECT ?pn ?gl
WHERE {
?person dbpedia-owl:gender ?g.
?person a dbpedia-owl:Person.
?person dbpprop:name ?pn.
{
?person dbpedia-owl:gender dbpedia:Male.
} UNION {
?person dbpedia-owl:gender dbpedia:Female.
}.
?g rdfs:label ?gl.
FILTER(lang(?gl) = "en").
}
但是,此查询只能捕获具有相应类型和性别的人员属性已设置。 Larry Page永远不会与当前数据集一起出现在该列表中,因为它没有相应的性别属性。作为另一个实际示例,请参见以下非常相似的查询,该查询返回不同的(非空)列表:
However, this query can capture only those persons for which the respective type and gender attributes are set. Larry Page will never appear in that list with the current dataset as it does not have the respective gender property. As another practical example see this very similar query, which returns a different (non-empty) list:
SELECT ?pn ?gl
WHERE {
?person dbpedia-owl:gender ?g.
?person a dbpedia-owl:Person.
?person dbpprop:name ?pn.
{
?person dbpedia-owl:gender dbpedia:Man.
} UNION {
?person dbpedia-owl:gender dbpedia:Woman.
}.
?g rdfs:label ?gl.
FILTER(lang(?gl) = "en").
}
另一个查询返回另一个列表:
Yet another query returns yet another list:
SELECT ?pn ?gl
WHERE {
?person ?gender ?gl.
?person a dbpedia-owl:Person.
?person dbpprop:name ?pn.
FILTER((?gl = "Female"@en) || (?gl = "Male"@en)).
}
编辑:自此以来,DBpedia的默认名称空间前缀已更改写这个答案。映射如下:
DBpedia's default namespace prefixes have changed since writing this answer. The mapping is as follows:
-
dbpedia
->http://dbpedia.org/resource/
(现在为dbr
) -
dbpedia-owl
->http://dbpedia.org/ontology/
(现在为dbo
) -
dbpprop
->http://dbpedia.org/property/
(现在为dbp
)
dbpedia
->http://dbpedia.org/resource/
(nowdbr
)dbpedia-owl
->http://dbpedia.org/ontology/
(nowdbo
)dbpprop
->http://dbpedia.org/property/
(nowdbp
)
这篇关于在SPARQL中获得特定人物的性别...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!