首页 > 解决方案 > 框架结合了 Apache Jena 和 Prolog 处理生产规则、三元组的功能

问题描述

这个问题似乎有点开放式。我正在使用算术运算符处理规则(主要是生产规则)。我还有一个本体,它定义了这些规则的元素之间的关系(这至少是初始设置)。例如

简单的例子

事实

NoOfItems('100')
BaseRental('300')

生产规则

Profit = (NoOfUnits * ProductionCostPerUnit) + TransportationCost - (NoOfUnits * SellingPricePerUnit)
TransportationCost = (FuelCost/Litre * FuelUsedInLitre) + DriverCost

本体:

Profit owl:sameAs ProfitPerQuarter
NoOfUnits owl:sameAs NoOfItems

我之前已经独立处理过这些,即使用 Prolog (SWI-Prolog) 处理生产类型的规则,甚至使用 Drools 在不同的场合处理它们。为了查询 RDF/OWL,我使用了 Apache Jena。包括在 Triple Store 上编写规则。

但是,你们能否建议一个可以同时处理这两种情况的框架,就像在这种情况下一样。我听说过 Prova,它可以处理这些。但是,Jena 或 Drools 是否有可以同时处理两者的推理器。

标签: prologdroolsjenarule-engine

解决方案


我也是 Apache Jena/Reasoners 等的新手。我使用 Apache Jena 推理器完成了类似的算术运算。Jena 推理模型中有许多内置函数可用。

正如您没有提到 RDF 三元组的样子,我假设以下格式。

:production :hasunits "100"^^xsd:int
:production :costperunit "20"^^xsd:int
:production :sellingprice "25"^^xsd:int

:production :fuelcostlitre "20"^^xsd:int
:production :fuelused "10"^^xsd:int
:production :drivercost "100"^^xsd:int

上述 RDF 的规则看起来像

 [r1: (?p :fuelcostlitre ?f) 
 (?p :fuelused ?l) (?p :drivercost ?d) product(?f ?l ?m)  sum(?m ?d ?s) 
  -> (?p :transportation ?s)]
 
 [r2: (?p :hasunits ?n) (?p :costperunit ?c) (?p :sellingprice ?m) 
 (?p :transportation ?t) product(?n ?c ?a)  product(?n ?m ?b) 
 sum(?a ?t ?e) difference(?e ?b ?d) 
 -> (?p :profit ?d)
 ]

有关 Jena 内置的更多信息,您可以参考此处。 https://jena.apache.org/documentation/inference/#RULEbuiltins


推荐阅读