简体   繁体   English

用Java评估逻辑谓词

[英]Evaluating Logical predicates in Java

I'm developing a Java application that manages a very large model of entities and their relationships. 我正在开发一个Java应用程序,该应用程序管理非常大的实体及其关系模型。 Such as "A uses B", "B is implemented in C", "C is located at D". 例如“ A使用B”,“ B用C实现”,“ C位于D”。 All these entities and their properties are stored in a noSQL database. 所有这些实体及其属性都存储在noSQL数据库中。

What I would like to do is have logical predicates such as: 我想做的是拥有逻辑谓词,例如:

  • B is used by A when A uses B 当A使用B时A使用B
  • A is dependant on C when A uses B and B is implemented in C 当A使用B并且在C中实现B时,A依赖于C

Then when a user opens the detail screen for A, he not only sees all A's properties but also sees: 然后,当用户打开A的详细信息屏幕时,他不仅会看到A的所有属性,还会看到:

  • A uses B A使用B
  • A is dependant on C A取决于C
  • A calls D A呼叫D

I can hardcode all those predicates, but I would like to be able to configure it. 我可以对所有这些谓词进行硬编码,但是我希望能够对其进行配置。 Does anyone have any idea how to approach that? 有谁知道如何解决这个问题?

I can't use SQL. 我不能使用SQL。 I don't have something like Prolog to invoke. 我没有像Prolog这样的东西可以调用。 There is a prolog emulator for Java, but I'm afraid it wants to load the entire datamodel in memory first, before evaluating predicates. 有一个Java的prolog模拟器,但恐怕它希望在评估谓词之前先将整个数据模型加载到内存中。

Any help is appreciated. 任何帮助表示赞赏。

There are several Java implementations of Prolog (eg Lean Prolog, JIProlog, tuProlog, Jekejeke Prolog, Minerva, ...). Prolog有几种Java实现(例如,精益Prolog,JIProlog,tuProlog,Jekejeke Prolog,Minerva等)。 Some provide a bi-directional interface between Prolog and Java. 有些提供了Prolog和Java之间的双向接口。 At least one of them, JIProlog, supports external Prolog databases of clauses, apparently allowing using those clauses without loading all of them into memory. 其中至少有一个JIProlog支持子句的外部Prolog数据库,显然可以在不将所有子句加载到内存的情况下使用这些子句。 If exporting the data from your noSQL database to a Prolog file is a feasible option, this might be a solution worth exploring. 如果将数据从noSQL数据库导出到Prolog文件是可行的选择,那么这可能是值得探讨的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM