SPIN:规则何时运行



我正在使用TopBraid免费版创建具有SPIN规则的OWL本体。我正在将本体和SPIN规则加载到Sesame OpenRDF Workbench中:

Application Name    OpenRDF Workbench
Version 4.1.2
Runtime Information
Operating System    Windows 8.1 6.3 (amd64)
Java Runtime    Oracle Corporation Java HotSpot(TM) 64-Bit Server VM (1.8.0_91)
Process User    Greg
Memory
Used    646 MB
Maximum 3463 MB

我创建了一个简单的测试本体。 它有一个类,一个 SPIN 规则和一个数据类型属性。

CONSTRUCT {
    ?this BugReproduction:hasTimeStamp ?timeStamp .
}
WHERE {
    BIND (now() AS ?timeStamp) .
}

SPIN 规则将xsd:dateTime时间戳添加到我的测试类的测试实例中。 以下是整个测试本体的RDF,包括我的类,数据类型属性和规则(简短):

    <?xml version="1.0"?>
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:sp="http://spinrdf.org/sp#"
    xmlns:BugReproduction="http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproduction#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:spin="http://spinrdf.org/spin#"
    xmlns:spl="http://spinrdf.org/spl#"
    xmlns:arg="http://spinrdf.org/arg#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
  xml:base="http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproduction">
  <owl:Ontology rdf:about="">
    <owl:imports rdf:resource="http://spinrdf.org/spl"/>
    <owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
    >Created with TopBraid Composer</owl:versionInfo>
  </owl:Ontology>
  <owl:Class rdf:ID="TimeStampBug">
    <rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    <spin:rule>
      <sp:Construct>
        <sp:templates rdf:parseType="Collection">
          <rdf:Description>
            <sp:object rdf:parseType="Resource">
              <sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
              >timeStamp</sp:varName>
            </sp:object>
            <sp:predicate>
              <owl:DatatypeProperty rdf:ID="hasTimeStamp"/>
            </sp:predicate>
            <sp:subject rdf:resource="http://spinrdf.org/spin#_this"/>
          </rdf:Description>
        </sp:templates>
        <sp:where rdf:parseType="Collection">
          <sp:Bind>
            <sp:expression>
              <sp:now/>
            </sp:expression>
            <sp:variable rdf:parseType="Resource">
              <sp:varName rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
              >timeStamp</sp:varName>
            </sp:variable>
          </sp:Bind>
        </sp:where>
      </sp:Construct>
    </spin:rule>
  </owl:Class>
  <owl:DatatypeProperty rdf:about="#hasTimeStamp">
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
  </owl:DatatypeProperty>
</rdf:RDF>
<!-- Created with TopBraid -->

因此,清除我在芝麻中的SPIN存储库并使用工作台的修改/添加命令(未选中"使用基本URI作为上下文标识符"框,这对于避免错误很重要)。 然后,我使用 SPARQL 更新查询创建类的测试实例:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX sxxicc: <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/SXXIComplianceCheck#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX sp: <http://spinrdf.org/sp#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX smf: <http://topbraid.org/sparqlmotionfunctions#>
PREFIX fn: <http://www.w3.org/2005/xpath-functions#>
PREFIX spl: <http://spinrdf.org/spl#>
PREFIX spin: <http://spinrdf.org/spin#>
PREFIX arg: <http://spinrdf.org/arg#>
PREFIX SXXIComplianceCheckIndividuals: <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/SXXIComplianceCheckIndividuals#>
PREFIX sxxicci: <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/SXXIComplianceCheckIndividuals#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX bugs: <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproduction#>
PREFIX bugsi: <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#>
INSERT DATA {
    bugsi:aTimeStampBug_test1 a bugs:TimeStampBug .
}

然后,我探索生成的bugsi:aTimeStampBug_test1个人,发现SPIN:rule已经运行了几次并产生了几个时间戳。 时间戳的数量因测试而异。 下面是一个示例结果:

Subject 
Predicate
Object
Context
<http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.571-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.592-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.594-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.595-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.596-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.597-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.598-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.599-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.600-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.601-05:00   
    <http://www.disa.mil/dso/a2i/ontologies/PBSM/Interface/BugReproductionInstantiations#aTimeStampBug_test1>
    BugReproduction:hasTimeStamp
    2016-07-11T20:56:58.602-05:00   

因此,我的 SPIN:rule 已经为类的一个实例化运行了几次。 SPIN:rule 应该为类的实例化运行多少次? 我以为它只会运行一次,但似乎我错了。

每当类的实例更改时,SPIN:rule都会在类的实例上运行。 我发布的示例设置了一个无限循环,由我的规则生成另一个规则运行生成另一个更改(新时间戳)等生成的更改,直到达到某个模糊的限制。 限制可能与芝麻的整体状态有关(例如资源或超时驱动),因此我得到了可变数量的时间戳。 一个简单的解决方案是改用仅在实例化时(断言类时)运行的SPIN:constructor,而不是在实例化更改时运行。

相关内容

  • 没有找到相关文章

最新更新