Den*_*off 11 sparql dbpedia virtuoso
我需要从DBpedia获取有关电影的数据.
我在http://dbpedia-live.openlinksw.com/sparql上使用SPARQL查询如下:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?subject ?label ?released WHERE {
?subject rdf:type <http://dbpedia.org/ontology/Film>.
?subject rdfs:label ?label.
?subject <http://dbpedia.org/ontology/releaseDate> ?released.
FILTER(xsd:date(?released) >= "2000-01-01"^^xsd:date).
} ORDER BY ?released
LIMIT 20
Run Code Online (Sandbox Code Playgroud)
我试图获得2000年1月1日之后发行的电影.但引擎答案如下:
Virtuoso 22007 Error DT006: Cannot convert 2009-06-31 to datetime :
Too many days (31, the month has only 30)
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?subject ?label ?released WHERE {
?subject rdf:type <http://dbpedia.org/ontology/Film>.
?subject rdfs:label ?label.
?subject <http://dbpedia.org/ontology/releaseDate> ?released.
FILTER(xsd:date(?released) >= "2000-01-01"^^xsd:date).
} ORDER BY ?released
LIMIT 20
Run Code Online (Sandbox Code Playgroud)
据我所知,DBpedia中的数据存在一些错误,引擎无法将字符串数据转换为日期类型,以便与我设置的日期进行比较.并且引擎会中断查询执行.
所以,问题是:有没有办法告诉引擎跳过所有错误的数据并返回给我所有可以处理的数据?
小智 1
一种方法是使用数据类型进行过滤,如下所示:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?subject ?label ?released WHERE {
?subject rdf:type <http://dbpedia.org/ontology/Film>.
?subject rdfs:label ?label.
?subject <http://dbpedia.org/ontology/releaseDate> ?released.
FILTER(datatype(?released) = <http://www.w3.org/2001/XMLSchema#dateTime>)
FILTER(xsd:date(?released) >= "2000-01-01"^^xsd:date).
} ORDER BY ?released
LIMIT 20
Run Code Online (Sandbox Code Playgroud)