使用 Virtuoso 设置 RDF 本体

发布于 2024-10-28 21:45:55 字数 180 浏览 4 评论 0原文

过去几个小时我一直在 google 上搜索有关如何使用 virtuoso 服务器(开源版本)配置 RDF 存储的教程或指南。

我有用 Protégé 软件创建的 RDF 文件。如何将此文件添加到 virtuoso 服务器并配置端点以便能够通过 Jena 或其他此类 API 插入/更新或查询数据。

I've googled for last few hours searching for tutorials or guides about how to configure RDF store with virtuoso server (open source version).

I have RDF file which was created with Protégé software. How can I add this file to virtuoso server and configure an end point to be able to insert/update or querying data via Jena or other API of that kind.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我不会写诗 2024-11-04 21:45:55

最简单的方法可能是这个文档页面 使用内容类型的 HTTP PUT:application/rdf+xml。该机制基本上运行一个 HTTP PUT 将您的文件发送到三元组存储。

curl -T your_file.rdf entity_uri_to_store_file -u user:pass

entity_uri_to_store_file 想象为您要保存该文件的表。

假设您的文件是ontology1.owl,并且您想将其保存在实体http://myorganise.com/ontologies/ontology1中,那么您的命令将类似于...

curl -T ontology1.owl http://myorganization.com/ontologies/ontology1 -u user:pass

注意:如果您运行的是 Windows 系统,您可以从 此处安装 curl

之后要查询数据...您也可以使用 curl 来完成。

curl -F“query=您的 SPARQL 查询”http://your.virtuososerver.org/sparql

请注意,您必须使用 SPARQL 来访问数据。

对于 Jena,您必须通过命令行使用 Jena ARQ ...

java -cp ... arq.query --service 'hhttp://your.virtuososerver.org/sparql' 'SELECT * WHERE {?s ?p ?o}'

或以编程方式使用 API ...

import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP;

public class QueryTest {

public static void main(String[] args) {
    String service = "http://your.virtuososerver.org/sparql";
    String query = "SELECT * WHERE {?s ?p ?o}";
    QueryExecution qe = QueryExecutionFactory.sparqlService(service, query);
    try {
       ResultSet results = qe.execSelect() ;
       for ( ; results.hasNext() ; ) {
           QuerySolution soln = results.nextSolution() ;
           RDFNode x = soln.get("s") ;
           RDFNode r = soln.get("p") ; 
           RDFNode l = soln.get("o") ;   
       }
    } catch (Exception e) {
        System.out.println("Query error:"+e);
    } finally {
        qe.close();
    }
 }

只需记住将变量 service 指向您的大师所在的位置服务器正在监听。

The easiest way to do it might be as explain on point (16.8.3) of this documentation page HTTP PUT using Content-Type: application/rdf+xml. This mechanism basically runs a HTTP PUT sending your file to the triple store.

curl -T your_file.rdf entity_uri_to_store_file -u user:pass

Think of entity_uri_to_store_file as if was the table where you want to save that file.

So lets say that your file is ontology1.owl and you want to save it in the entity http://myorganisation.com/ontologies/ontology1 your command then would look like ...

curl -T ontology1.owl http://myorganisation.com/ontologies/ontology1 -u user:pass

Note: if you're running a Windows box you can install curl from here.

To query the data afterwards ... you can also do it with curl.

curl -F "query=YOUR SPARQL QUERY" http://your.virtuososerver.org/sparql

Notice that you have to use SPARQL to access the data.

In the case of Jena, you have to use Jena ARQ, by command line ...

java -cp ... arq.query --service 'hhttp://your.virtuososerver.org/sparql' 'SELECT * WHERE {?s ?p ?o}'

or programatically by using the API ...

import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.sparql.engine.http.QueryExceptionHTTP;

public class QueryTest {

public static void main(String[] args) {
    String service = "http://your.virtuososerver.org/sparql";
    String query = "SELECT * WHERE {?s ?p ?o}";
    QueryExecution qe = QueryExecutionFactory.sparqlService(service, query);
    try {
       ResultSet results = qe.execSelect() ;
       for ( ; results.hasNext() ; ) {
           QuerySolution soln = results.nextSolution() ;
           RDFNode x = soln.get("s") ;
           RDFNode r = soln.get("p") ; 
           RDFNode l = soln.get("o") ;   
       }
    } catch (Exception e) {
        System.out.println("Query error:"+e);
    } finally {
        qe.close();
    }
 }

Just remember to point the variable service to where your virtuoso server is listening.

未蓝澄海的烟 2024-11-04 21:45:55

从 Virtuoso Conductor (http:cname:8890/conductor) 中,您可以转到“RDF -> RDF Store Upload”选项卡,您可以在其中从文件系统或 URL 位置上传 RDF 数据集文件。

Virtuoso Jena Provider 可用于使用以下命令查询 Virtuoso Quad Store:耶拿框架。

From the Virtuoso Conductor (http:cname:8890/conductor) you can go to the "RDF -> RDF Store Upload" tab where you can upload RDF datasets file from file system or a URL location.

The Virtuoso Jena Provider can be used for querying the Virtuoso Quad Store using the Jena Franework.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文