第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

如何在python中的sparqlwrapper中添加特殊類別

如何在python中的sparqlwrapper中添加特殊類別

翻翻過去那場雪 2021-12-08 16:09:41
我使用 sparqlwrapper 使用以下 sparql 查詢,如下所示。from SPARQLWrapper import SPARQLWrapper, JSONsparql = SPARQLWrapper("http://live.dbpedia.org/sparql")sparql.setReturnFormat(JSON)my_category = 'dbc:Meteorological_concepts'sparql.setQuery(f" ASK {{ {my_category}  skos:broader{{1,3}} dbc:Medicine }} ")results = sparql.query().convert()print(results['boolean'])如上所述,它適用于沒有括號的類別(例如,dbc:Meteorological_concepts)。但是,當(dāng)我輸入帶括號(即my_category = dbc:Elasticity_(physics))的類別時(shí),出現(xiàn)以下錯(cuò)誤。b"Virtuoso 37000 Error SP030: SPARQL compiler, line 4: syntax error at 'physics' before ')'\n\nSPARQL query:\ndefine sql:big-data-const 0 \n#output-format:application/sparql-results+json\n\n    ASK { dbc:Elasticity_(physics) skos:broader{1,3} dbc:Medicine }\n"CRITICAL: Exiting due to uncaught exception <class 'SPARQLWrapper.SPARQLExceptions.QueryBadFormed'>有沒有辦法解決這個(gè)問題。如果需要,我很樂意提供更多詳細(xì)信息。
查看完整描述

1 回答

?
白板的微信

TA貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個(gè)贊

我正在重寫@StanislavKralin 在上述評論中提到的內(nèi)容。我總是嘗試在 SPARQL 代碼中使用完整 URL,特別是當(dāng) SPARQL 查詢中有特殊字符時(shí)。


from SPARQLWrapper import SPARQLWrapper, JSON

sparql = SPARQLWrapper("http://live.dbpedia.org/sparql")

sparql.setReturnFormat(JSON)

my_category = '<http://dbpedia.org/resource/Category:Elasticity_(physics)>'

sparql.setQuery(f" ASK {{ {my_category}  skos:broader{{1,3}} dbc:Medicine }} ")

results = sparql.query().convert()

print(results['boolean'])


查看完整回答
反對 回復(fù) 2021-12-08
  • 1 回答
  • 0 關(guān)注
  • 211 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號