“本体 owl 和 Excel 数据”

huangapple go评论112阅读模式
英文:

Ontology owl and Excel data

问题

我是一个非程序员。我有一个以owl格式的本体。我还有一个Excel表格(其中包含选定本体的带有标题的数值数据)。现在我需要将Excel标题与本体框架连接起来,并需要从本体中提取Excel数据中的链接。

英文:

I am a non programmer. I have a ontology in owl format. I also have an excel sheet (it contains data numeric data with headers of selected ontology). Now I have to connect the excel header with ontology framework and need to extract the links in excel data from the ontology.

答案1

得分: 4

我正确理解您的意思,您有一个由OWL本体描述的RDF知识库,您希望将这些数据从RDF导入到电子表格中。

将RDF转换为电子表格的最直接方式是使用SPARQL SELECT查询。

先决条件

如果您尚未将数据存储在可以直接查询的应用程序或端点中(例如,Protégé可能具有用于SPARQL查询的小部件),则有三个先决条件,否则请跳过这些:

1. 导出/转换数据

如果您的数据存储在无法执行SPARQL查询的应用程序中,或者以OWL/XML等语法格式的文件形式存在,那么您需要首先将其转换,因为大多数SPARQL端点不理解这种格式,而是需要RDF序列化,例如N-Triples、RDF Turtle或RDF/XML等格式,因此您需要将数据导出为其中一种格式。

2. 设置SPARQL端点

现在,您可以安装例如Virtuoso SPARQL端点,可以在本地安装,也可以在服务器上安装,或者使用其他人提供的具有访问凭据的端点。安装可能需要一些时间,但如果更容易,您可以使用Docker镜像。

3. 上传数据

在Virtuoso SPARQL中,您现在可以在“Linked Data” -> “Quad Store Upload”下上传本体和实例数据。

查询

我不知道是否有任何现有工具可以自动映射本体并根据给定的Excel表模板下载实例,因此我建议手动创建SPARQL SELECT查询

示例

假设您的Excel表具有标题行 "name"、"age" 和 "height"(您说您有数值数据),而本体在RDF Turtle中定义了一个类似于以下内容的人物类:

:Person a owl:Class;
        rdfs:label "Person"@en.

:age a owl:DatatypeProperty;
  rdfs:label "age"@en;
  rdfs:domain :Person;
  rdfs:range xsd:nonNegativeInteger.

:height a owl:DatatypeProperty;
  rdfs:label "height"@en;
  rdfs:domain :Person;
  rdfs:range xsd:decimal.

现在,您可以编写以下SPARQL SELECT查询:

PREFIX :<http://my.prefix/>
SELECT ?person ?age ?height
{
 ?person a :Person;
         :age ?age;
         :height ?height.
}

这将生成一个结果表,您可以以不同格式获取。选择CSV电子表格格式,然后您可以将其导入到MS Excel中,这将解决您的问题,至少从我理解的角度来看。

英文:

Do I understand you correctly that you have an RDF knowledge base whose schema is described by an OWL ontology and you want to import this data from RDF to a spreadsheet?

The most straightforward case to transform RDF to spreadsheets is a SPARQL SELECT query.

Prerequisites

If you don't already have the data in an application or endpoint where you can query it directly (e.g. Protégé may have a widget for SPARQL queries), there are three prerequisites, else skip those:

1. Export/Convert the Data

If you have your data in an application where you can't perform SPARQL queries or as a file in a syntax such as OWL/XML, you need to convert it first, because most SPARQL endpoints don't understand this format, but rather need an RDF serialization such as N-Triples, RDF Turtle or RDF/XML, so you need to export the data in one of those formats.

2. Setup a SPARQL Endpoint

Now you can install e.g. a Virtuoso SPARQL endpoint, either locally or on a server or use the endpoint of someone else who gives you access credentials.
It can take a while to install but you can use a Docker image if that is easier.

3. Upload the Data

In Virtuoso SPARQL, you can now upload the ontology and the instance data in the conductor under "Linked Data" -> "Quad Store Upload".

Querying

I don't know of any existing tool that automatically maps ontologies and downloads instances according to a given Excel sheet templates so I recommend to create a SPARQL SELECT query manually.

Example

Let's say your Excel sheet has the header rows "name", "age" and "height" (you said you have numeric data) and the ontology has a person class defined like this in RDF Turtle:

:Person a owl:Class;
        rdfs:label &quot;Person&quot;@en.

:age a owl:DatatypeProperty;
  rdfs:label &quot;age&quot;@en;
  rdfs:domain :Person;
  rdfs:range xsd:nonNegativeInteger.

:height a owl:DatatypeProperty;
  rdfs:label &quot;height&quot;@en;
  rdfs:domain :Person;
  rdfs:range xsd:decimal.

Now you can write the following SPARQL SELECT query:

PREFIX :&lt;http://my.prefix/&gt;
SELECT ?person ?age ?height
{
 ?person a :person;
         :age ?age;
         :height ?height.
}

This will generate a result table, which you can obtain in different formats. Choose the CSV spreadsheet format and then you can import it into MS Excel, which solves your problem as far as I interpret it.

huangapple
  • 本文由 发表于 2020年8月11日 19:57:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/63357644.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定