找回密码
 注册
查看: 619|回复: 0

R语言 SPARQL包 SPARQL()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 12:28:15 | 显示全部楼层 |阅读模式
SPARQL(SPARQL)
SPARQL()所属R语言包:SPARQL

                                         SPARQL client
                                         SPARQL客户端

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

This function connects to a SPARQL end-point over HTTP, poses a SELECT query or an update query (LOAD, INSERT, DELETE). If given a SELECT query it returns the results as a data frame with a named column for each variable from the SELECT query, a list of prefixes and namespaces that were shortened to qnames is also returned. If given an update query nothing is returned. If the parameter "query" is given, it is assumed the given query is a SELECT query and a GET request will be done to get the results from the URL of the end point. Otherwise, if the parameter "update" is given, it is assumed the given query is an update query and a POST request will be done to send the request to the URL of the end point.
这个函数连接到一个HTTP SPARQL终点,构成一个SELECT查询或更新查询(装载,插入,删除)。如果给定一个SELECT查询返回的结果作为一个数据框的每个变量命名列的SELECT查询,也将返回缩短至QName的前缀和命名空间的列表。如果给定了更新查询不返回任何值。如果参数“查询”,这是假设给定的查询是一个SELECT查询和一个GET请求的URL的终点,将得到的结果。否则,如果该参数是“更新”,假设给出的查询更新查询,将做一个POST请求来发送请求的结束点的URL。


用法----------Usage----------


SPARQL(url = "http://localhost/", query = "", update="", ns = NULL, param = "", extra = NULL, format="xml")



参数----------Arguments----------

参数:url
The URL of the SPARQL end-point.  
URL的SPARQL终点。


参数:query
A SPARQL SELECT query to fire at the end-point.  
SPARQL SELECT查询开火终点。


参数:update
A SPARQL update query (LOAD, INSERT, DELETE)) to fire at the end-point.  
一个SPARQL更新查询(LOAD,INSERT,DELETE))到火的终点。


参数:ns
Prefixes to shorten IRIs returned by the SPARQL end-point. For example,  <PRE>ns=c('dc','<http://purl.org/dc/elements/1.1/>',      'rdfs','<http://www.w3.org/2000/01/rdf-schema#>')</PRE> will shorten the IRIs 'http://purl.org/dc/elements/1.1/title' to 'dc:title' and 'http://www.w3.org/2000/01/rdf-schema#label' to 'rdfs:label'.  
前缀缩短虹膜返回的SPARQL终点。例如,<PRE>纳秒= C(在“dc,<http://purl.org/dc/elements/1.1/>,的rdfs,<http://www.w3。 org/2000/01/rdf-schema#>)</ pre>将缩短的虹膜'http://purl.org/dc/elements/1.1/title''dc:title'和'http://www.w3.org/2000/01/rdf-schema#label'到'rdfs:label'。


参数:param
By default a SPARQL end-point accepts queries in the "query" HTTP parameter and updates in the "update" parameter. If the end-point uses a different parameter you can specify this here.  
默认情况下,SPARQL终点接受"query" HTTP参数和更新"update"参数的查询。如果最终点使用不同的参数,你可以指定在这里。


参数:extra
Extra parameters and their values that will be added to the HTTP request. Some SPARQL end-points require extra parameters to work. These can be supplied, in URL encoded form, as a character vector with this parameter. This field can be used to specify the various ways in which different end-points can be told to return a certain format. For example, extra=list(resultFormat="xml") or extra=list(output="xml",queryLn="SPARQL")  
额外的参数和它们的值将被添加到HTTP请求中。一些SPARQL端点需要额外的参数来工作。这些可以提供URL编码的形式,作为一个字符向量,这个参数。可以使用此字段指定的各种方式,其中不同的结束点可以被告知返回一定的格式。例如,额外的列表(resultFormat =“XML”)或额外=列表(输出=“XML”,queryLn =“SPARQL”)


参数:format
Can be used to explicitly state what kind of format is returned by the output. This version supports "xml", "csv" and "tsv".  
可用于明确说明什么样的格式,则返回的输出。此版本支持“XML”,“CSV”和“TSV”。


值----------Value----------

The returned data frame contains a column for each variable in the SELECT query. For example, the query "SELECT * WHERE { ?s ?p ?o . } LIMIT 10" will yield three columns named "s", "p", and "o". The query "SELECT ?s WHERE { ?s ?p ?o . } LIMIT 10" will yield only one column named "s".      
返回的数据框都包含一列的SELECT查询中的每个变量。例如,查询"SELECT * WHERE { ?s ?p ?o . } LIMIT 10"将产生三列名为“s”,“P”和“o”。的查询"SELECT ?s WHERE { ?s ?p ?o . } LIMIT 10"将产生一列名为“s”。


(作者)----------Author(s)----------



Willem Robert van Hage and Tomi Kauppinen




参考文献----------References----------

SPARQL Update specification, http://www.w3.org/TR/sparql11-update/.<br> Examples of SPARQL end-points, http://www.w3.org/wiki/SparqlEndpoints.

实例----------Examples----------


d <- SPARQL(url="http://services.data.gov.uk/reference/sparql",
            query="SELECT * WHERE { ?s ?p ?o . } LIMIT 10",
            ns=c('time','&lt;http://www.w3.org/2006/time#&gt;'))[>))]

is.data.frame(d$results)

# draw a pie chart from data from the Linked Open Piracy data set[相连的休憩盗版数据集的数据,绘制饼图]
endpoint <- "http://semanticweb.cs.vu.nl/lop/sparql/"
q <-
  "SELECT *
   WHERE {
     ?event sem:hasPlace ?place .
     ?place eez:inPiracyRegion ?region .
   }"
prefix <- c("lop","http://semanticweb.cs.vu.nl/poseidon/ns/instances/",
            "eez","http://semanticweb.cs.vu.nl/poseidon/ns/eez/")
res <- SPARQL(endpoint,q,prefix)$results
pie(sort(table(res$region)),col=rainbow(12))

# draw a stacked bar chart from data from the Linked Open Piracy data set[画一个堆积条形图数据从数据集相连的休憩盗版]
q <-
  "SELECT *
   WHERE {
     ?event sem:eventType ?event_type .
     ?event sem:hasPlace ?place .
     ?place eez:inPiracyRegion ?region .
   }"
res <- SPARQL(endpoint,q,ns=prefix)$results
restable <- table(res$event_type,res$region)
par(mar=c(4,10,1,1))
barplot(restable,col=rainbow(10),horiz=TRUE,las=1,cex.names=0.8)
legend("topright",rownames(restable),
       cex=0.8,bty="n",fill=rainbow(10))

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-6-9 22:58 , Processed in 0.023596 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表