2016-11-24 36 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($)」所說的。