问题
I want to extract all statements from DBPedia's dump file.
Is it possible to write a sparql query to extract the list of predicates which contains the date values (like releaseDate, deathDate, birthDate,...)?
回答1:
You can write a SPARQL query (you tagged with SPARQL, so presumably that's how you want to query for these things) that finds these kind of properties. All you need to do is query for things which are owl:DatatypeProperties (since dates should be literals), and then filter based on their string representation. For instance:
select ?p where {
?p a owl:DatatypeProperty
filter( contains( str(?p), "Date" ) || contains( str(?p), "date" ))
}
limit 100
SPARQL results
Now, that will return any property whose string form contains the strings “Date” or “date”. You'll find that most of those are the kind of things you're looking for. However, a better way to do this might be to search for things that have xsd:date as their range, using a query like this:
select ?p where {
?p a owl:DatatypeProperty ;
rdfs:range xsd:date .
}
limit 100
SPARQL results
This has the advantage that you'll get properties whose values should be dates, even if their name doesn't include date. For instance, you'll get:
- http://dbpedia.org/ontology/closed;
- http://dbpedia.org/ontology/discovered;
- http://dbpedia.org/ontology/finalFlight;
- … and so on.
来源:https://stackoverflow.com/questions/18579620/extract-date-time-based-predicates-from-dbpedia