2016-11-24 38 views
0

嗨下面是我在https://dbpedia.org/sparql上执行的sparql查询。但是,由于总收入中存在一些字符值,并且如果我将查询更改为str(?grossincome)作为?grossincome1),我得到一个错误“无效浮点值转换”美国:'“,因此它会正确执行。我的问题是如何转换所有货币相同的规模,以避免这个错误?运行sparql查询获取浮点值

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX dcterms: <http://purl.org/dc/terms/>  
PREFIX dbo: <http://dbpedia.org/ontology/> 
PREFIX dbp: <http://dbpedia.org/property/> 
PREFIX foaf: <http://xmlns.com/foaf/0.1/> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 

select distinct (str(?resource) as ?movietitle) (xsd:float(?budget) as ?budget1) (xsd:float(?grossincome) as ?grossincome1) (str(?Country) as ?country1) ?ReleaseDate where { 
      ?movie foaf:name ?resource. 
      ?movie dbo:budget ?budget. 
      ?movie dbp:gross ?grossincome. 
      ?movie dbp:country ?Country. 
      ?movie dbo:releaseDate ?ReleaseDate. 
      FILTER (lang(?resource) = 'en'). 
    } 

回答

3

在DBpedia中的数据是不完美的,因为你已经认识到它是无类型物业dbp:gross相当异类。其中包含BDT 2.52 crores,$34,994,648 USD,AU$178,000,6892098.0等值,因此通过SPARQL查询处理不同货币几乎是不可能的,因此它将返回相同货币的值。

我的意思是,你将不得不知道所有不同的货币和格式发生,然后分别处理。但这更多的是应用程序逻辑的任务,而不是查询本身。

或者,您可以尝试使用数据属性http://dbpedia.org/ontology/gross代替,它应该与$中的值相关。至少这就是它的标签“gross($)”所说的。