我的问题是,如果我想检查实例是否在范围内,则使用以下规则:

Rule1: Error(?d), TimeRelatedError(?c), TimeRelatedError_start_at(?c, ?s), error_at(?d, ?b), greaterThan(?b, ?s) -> is_after_TimeRelatedError_start(?d, true)
Rule2: Error(?d), TimeRelatedError(?c), TimeRelatedError_end_at(?c, ?e), error_at(?d, ?b), lessThan(?b, ?e) -> is_before_TimeRelatedError_end(?d, true)


如果我的本体中只有一个TimeRelatedError,如果我有更多的实例,它将总是触发true(因为其中一个TimeRelatedError总是在起点/终点之前/之后)。您是否有解决此问题的想法?我认为如果我以某种方式将TimeRelatedError分配给Error实例,但我不知道如何解决该问题。请OWL / SWRL专业人员帮助我完成此任务:)

最佳答案

我只能怪我自己,我找到了解决办法,只有一条法则:

Error(?d), TimeRelatedError(?c), TimeRelatedError_start_at(?c, ?s), error_at(?d, ?b), greaterThan(?b, ?s), TimeRelatedError_end_at(?c, ?e), error_at(?d, ?b), lessThan(?b, ?e) -> in_range(?d, true)


之所以起作用,是因为GreaterThan之后的所有内容仅在语句(greaterThan)为真时才被调用,最后如果结尾也小于,则可以将其称为in_range。我将其留在这里,以供其他偶然发现同一问题的人使用。

关于python - OWL2,SWRL:查询项目是否在另一个项目的范围内?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57380749/

10-14 12:42
查看更多