我以RDF / XML格式制作了本体的简化示例。这是在问题的最后。我使用Protégé5.0beta。
解释我的请求的图片:
我总结一下:
两个1级:流程,产品
三个子类流程: process_1 , process_2 , process_3
< / LI>每个流程都有许多自己的成员,这些成员链接到具有输入或输出
process_n的每个成员都有名为数量的数据属性。
如果你能帮我解决语法问题,那可能会很好,但主要是因为我需要帮助。
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY untitled-ontology-14 "http://www.semanticweb.org/francocy/ontologies/2015/1/untitled-ontology-14#" >
]>
<rdf:RDF xmlns="http://www.semanticweb.org/francocy/ontologies/2015/1/untitled-ontology-14#"
xml:base="http://www.semanticweb.org/francocy/ontologies/2015/1/untitled-ontology-14"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:untitled-ontology-14="http://www.semanticweb.org/francocy/ontologies/2015/1/untitled-ontology-14#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/francocy/ontologies/2015/1/untitled-ontology-14"/>
<owl:ObjectProperty rdf:about="&untitled-ontology-14;input"/>
<owl:ObjectProperty rdf:about="&untitled-ontology-14;output">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
</owl:ObjectProperty>
<owl:DatatypeProperty rdf:about="&untitled-ontology-14;quantity"/>
<owl:Class rdf:about="&untitled-ontology-14;process"/>
<owl:Class rdf:about="&untitled-ontology-14;process_1">
<rdfs:subClassOf rdf:resource="&untitled-ontology-14;process"/>
</owl:Class>
<owl:Class rdf:about="&untitled-ontology-14;process_2">
<rdfs:subClassOf rdf:resource="&untitled-ontology-14;process"/>
</owl:Class>
<owl:Class rdf:about="&untitled-ontology-14;process_3">
<rdfs:subClassOf rdf:resource="&untitled-ontology-14;process"/>
</owl:Class>
<owl:Class rdf:about="&untitled-ontology-14;products"/>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_1_of_process_1">
<rdf:type rdf:resource="&untitled-ontology-14;process_1"/>
<quantity rdf:datatype="&xsd;integer">5</quantity>
<input rdf:resource="&untitled-ontology-14;product_2"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_1_of_process_2">
<rdf:type rdf:resource="&untitled-ontology-14;process_2"/>
<quantity rdf:datatype="&xsd;integer">3</quantity>
<input rdf:resource="&untitled-ontology-14;product_4"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_1_of_process_3">
<rdf:type rdf:resource="&untitled-ontology-14;process_3"/>
<quantity rdf:datatype="&xsd;integer">2</quantity>
<input rdf:resource="&untitled-ontology-14;product_2"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_2_of_process_1">
<rdf:type rdf:resource="&untitled-ontology-14;process_1"/>
<quantity rdf:datatype="&xsd;integer">2</quantity>
<input rdf:resource="&untitled-ontology-14;product_3"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_2_of_process_2">
<rdf:type rdf:resource="&untitled-ontology-14;process_2"/>
<quantity rdf:datatype="&xsd;integer">10</quantity>
<input rdf:resource="&untitled-ontology-14;product_5"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;input_2_of_process_3">
<rdf:type rdf:resource="&untitled-ontology-14;process_3"/>
<quantity rdf:datatype="&xsd;integer">3</quantity>
<input rdf:resource="&untitled-ontology-14;product_4"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;output_1_of_process_1">
<rdf:type rdf:resource="&untitled-ontology-14;process_1"/>
<quantity rdf:datatype="&xsd;integer">1</quantity>
<output rdf:resource="&untitled-ontology-14;product_1"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;output_1_of_process_2">
<rdf:type rdf:resource="&untitled-ontology-14;process_2"/>
<quantity rdf:datatype="&xsd;integer">1</quantity>
<output rdf:resource="&untitled-ontology-14;product_2"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;output_1_of_process_3">
<rdf:type rdf:resource="&untitled-ontology-14;process_3"/>
<quantity rdf:datatype="&xsd;integer">1</quantity>
<output rdf:resource="&untitled-ontology-14;product_3"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;product_1">
<rdf:type rdf:resource="&untitled-ontology-14;products"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;product_2">
<rdf:type rdf:resource="&untitled-ontology-14;products"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;product_3">
<rdf:type rdf:resource="&untitled-ontology-14;products"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;product_4">
<rdf:type rdf:resource="&untitled-ontology-14;products"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="&untitled-ontology-14;product_5">
<rdf:type rdf:resource="&untitled-ontology-14;products"/>
</owl:NamedIndividual>
</rdf:RDF>
答案 0 :(得分:0)
感谢您对本体的清理和重做。但是,我仍然认为这不是捕捉你想要表达的东西的好方法。例如,您的本体包括,以N3表示法):
untitled-ontology-14:input_2_of_process_1
a owl:NamedIndividual , untitled-ontology-14:process_1 ;
untitled-ontology-14:input untitled-ontology-14:product_3 ;
untitled-ontology-14:quantity 2 .
untitled-ontology-14:input_1_of_process_1
a owl:NamedIndividual , untitled-ontology-14:process_1 ;
untitled-ontology-14:input untitled-ontology-14:product_2 ;
untitled-ontology-14:quantity 5 .
untitled-ontology-14:output_1_of_process_1
a owl:NamedIndividual , untitled-ontology-14:process_1 ;
untitled-ontology-14:output untitled-ontology-14:product_1 ;
untitled-ontology-14:quantity 1 .
这是 process_1 类的三个实例。我认为这些是名为 process_1 的类的实例是不合理的。
相反,我认为有一些不同的过程,它恰好有两个输入和一个输出。每个输入和输出都是一对数量和特定产品。
我在N3或RDF / XML中使用类似的方式表示您的流程。 (我现在打算在纯RDF中工作;转换为OWL只是声明一些类和属性的问题;毕竟这是关于SPARQL的问题,而SPARQL是 RDF查询语言< / em>的。)
@prefix : <urn:ex:> .
:process1 a :Process ;
:hasInput [ a :Measure ; :quantity 2 ; :product :product3 ] ,
[ a :Measure ; :quantity 5 ; :product :product2 ] ;
:hasOutput [ a :Measure ; :quantity 1 ; :product :product1 ] .
:process2 a :Process ;
:hasInput [ a :Measure ; :quantity 3 ; :product :product4 ] ,
[ a :Measure ; :quantity 10 ; :product :product5 ] ;
:hasOutput [ a :Measure ; :quantity 1 ; :product :product2 ] .
:process3 a :Process ;
:hasInput [ a :Measure ; :quantity 2 ; :product :product2 ] ,
[ a :Measure ; :quantity 3 ; :product :product4 ] ;
:hasOutput [ a :Measure ; :quantity 1 ; :product :product3 ] .
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="urn:ex:">
<Process rdf:about="urn:ex:process3">
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>2</quantity>
<product rdf:resource="urn:ex:product2"/>
</Measure>
</hasInput>
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>3</quantity>
<product rdf:resource="urn:ex:product4"/>
</Measure>
</hasInput>
<hasOutput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>1</quantity>
<product rdf:resource="urn:ex:product3"/>
</Measure>
</hasOutput>
</Process>
<Process rdf:about="urn:ex:process2">
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>3</quantity>
<product rdf:resource="urn:ex:product4"/>
</Measure>
</hasInput>
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>10</quantity>
<product rdf:resource="urn:ex:product5"/>
</Measure>
</hasInput>
<hasOutput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>1</quantity>
<product rdf:resource="urn:ex:product2"/>
</Measure>
</hasOutput>
</Process>
<Process rdf:about="urn:ex:process1">
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>2</quantity>
<product rdf:resource="urn:ex:product3"/>
</Measure>
</hasInput>
<hasInput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>5</quantity>
<product rdf:resource="urn:ex:product2"/>
</Measure>
</hasInput>
<hasOutput>
<Measure>
<quantity rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
>1</quantity>
<product rdf:resource="urn:ex:product1"/>
</Measure>
</hasOutput>
</Process>
</rdf:RDF>
当然,这并不是解决问题,而且我不确定您是否可以使用SPARQL进行所需的所有计算,尤其是当有多种方法时生产各种产品,但你至少可以开始编写这样的查询,这将有助于你弄清楚你需要什么来生产东西,以及哪些过程可以提供帮助:
prefix : <urn:ex:>
select * where {
?process :hasOutput [ :quantity ?q ; :product :product1 ] ;
:hasInput [ :quantity ?inputq ; :product ?input ] .
?input ^:product/^:hasOutput ?subprocess
}
---------------------------------------------------
| process | q | inputq | input | subprocess |
===================================================
| :process1 | 1 | 5 | :product2 | :process2 |
| :process1 | 1 | 2 | :product3 | :process3 |
---------------------------------------------------