如何使R中的SPARQL查询可以读取URI中的空格?

问题描述:

当我们在Virtuoso中编写SPARQL时,通过使用%20对空间进行编码,可以轻松地在URI内跳过一个空格。但是,当我在R中安装SPARQL包时,转义失败。在命令SPARQL中有一个参数curl_args,它应该解决此问题。但它并不成功。这里是我的R脚本:如何使R中的SPARQL查询可以读取URI中的空格?

###Step 1: Building up the query 

query <-"select ?instance { 
?form a <URI name> . 
?instance a <http://StemAddress/Where My Question Is> . 
}" 
###Step 2: Executing the query 
qd <- SPARQL(endpoint,queryC,curl_args = curlPercentEncode("http://StemAddress/Where My Question Is", amp = TRUE, codes = " ", post.amp = TRUE)) 


####In Step 1, what it works in Virtuoso is 
select ?instance { 
?form a <URI name> . 
?instance a <http://StemAddress/Where%20My%20Question%20Is> . 
} 

####But this just threw me an error in R environment. 
+0

抛出了什么错误?你有没有检查R如何编码查询字符串? – AKSW

+0

你试过'+'吗? – Termininja

+0

我尝试了+也没有被识别,错误信息是“有非法字符”。 – user123871

写作%20是不是一个空间逃生。它确实是URI中的三个字符%-2-0。编码!=转义。 URI中的空格是非法的。

+0

我将%20替换为%-2-0,并且错误消息“URL中发现的非法字符”消失,但查询结果为空。我相信那里有数据。 – user123871

+0

3个字符“%20”(我强调单独的字符是“%-2-0” – AndyS