在Jena API中,为什么即使条件不满足也会触发规则?

时间:2018-06-30 15:04:28

标签: jena ontology

我有以下规则:

[startsystem_ini: 
  (?systeminfo hvac:SYS_isstart 'true'^^xsd:boolean),
  (?systeminfo rdf:type hvac:SystemInfo),
  (?systeminfo hvac:SYS_currenttime ?time)
->
 drop(0),
 (?systeminfo hvac:SYS_isstart 'false'^^xsd:boolean),
 (?systeminfo hvac:SYS_onoffStatus 'false'^^xsd:boolean),
 (?systeminfo hvac:SYS_AllowAdjustLevelTime ?time),
 print('deleted the SYS_isstart on ', ?time)]

我在每个循环中通过删除旧值并在Java中使用Jena插入一个新值来更新(?systeminfo hvac:SYS_currenttime ?time)的值。 (?systeminfo hvac:SYS_isstart 'true'^^xsd:boolean)的值在循环的最开始就设置一次。

我发现此规则在每个循环中均被触发。我尝试使用SPARQL打印SYS_onoffStatus的值。在每个循环中,该值始终为false。

java代码中的配置为asl如下:

    GenericRuleReasoner reasoner = new GenericRuleReasoner(rules);
    reasoner.setOWLTranslation(true); // not needed in RDFS case
    reasoner.setTransitiveClosureCaching(true);
    reasoner.setParameter(ReasonerVocabulary.PROPruleMode, "forwardRETE");
    try {
        InputStream ont_stream = new ByteArrayInputStream(ont.getBytes());
        OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF);
        model.read(ont_stream, null, "TTL");// read the file
        infmodel = ModelFactory.createInfModel(reasoner, model);

这很奇怪!有人可以帮我吗?

0 个答案:

没有答案