请求确定特定成员的数量 类 与乘数链接在一起

Request to determine the quantity of a specific members in several classes linked together with a multiplier

我以 RDF/XML 格式制作了一个 ontology 的简化示例。它在问题的末尾。我使用 Protégé 5.0 beta。

解释我的请求的图片:

我总结一下:

如果你能在语法方面帮助我,那会很好,但主要是因为我需要帮助的推理。

Ontology (RDF/XML)

<?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>

感谢您对 ontology 进行了如此多的清理和返工。但是,我仍然认为这不是捕捉您要表达的内容的好方法。例如,您的 ontology 包括,以 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 .

这是 classprocess_1 的三个 实例。我认为这些是名为 process_1 的 class 的实例是没有意义的。

相反,我认为有一些不同的过程,它恰好有两个输入和一个输出。每个输入和输出都是一对数量和特定产品。

我会在 N3 或 RDF/XML 中用类似的东西来表示您的流程。 (目前我打算使用纯 RDF;转换为 OWL 只是声明一些 classes 和属性的问题;毕竟这是关于 SPARQL 的问题,而 SPARQL 是一个RDF 查询语言.)

@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  |
---------------------------------------------------