質問

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 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:

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

typically but not necessarily 'male' or 'female'

).


The following query, for example, returns the gender of 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").
}

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)).
}

EDIT: DBpedia's default namespace prefixes have changed since writing this answer. The mapping is as follows:

  • dbpedia -> http://dbpedia.org/resource/ (now dbr)
  • dbpedia-owl -> http://dbpedia.org/ontology/ (now dbo)
  • dbpprop -> http://dbpedia.org/property/ (now dbp)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top