快速加载流口水知识库

发布于 2024-10-04 00:54:25 字数 167 浏览 2 评论 0原文

我正在尝试使用 Drools 作为语法关系到语义映射框架的规则引擎。规则库目前已超过 5000 条规则,并将继续扩展。当前使用 Drools 时,每次运行程序时,读取包含规则的 drl 文件和创建知识库都需要花费大量时间。有没有办法创建一次知识库并将其保存为某种持久格式,可以快速加载仅在进行更改时重新生成知识库的选项?

I'm trying to use Drools as the rule engine for a grammar relations to semantics mapping framework. The rule base is in excess of 5000 rules even now and will get extended. In using Drools currently the reading of the drl file containing the rules and creating the knowledge base takes a lot of time each time the program is run. Is there a way create the knowledge base once and save it in some persistent format that can be quickly loaded with the option to regenerate the knowledge base only when a change is made?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月光色 2024-10-11 00:54:25

是的,drools 可以将知识库序列化到外部存储,然后再次加载该序列化的知识库。

因此,您需要一个从 drl 加载、编译、序列化的循环。然后是使用序列化版本的第二个周期。

我使用此方法取得了一些成功,将 1 分 30 秒的加载时间减少到大约 15-20 秒。此外,它还减少了堆/永久代的要求。

检查 API 以获取确切的方法。

Yes, drools can serialise a knowledgebase out to external storage and then load this serialised knowledgebase back in again.

So, you need a cycle that loads from drl, compiles, serialises out. Then a second cycle that uses the serialised version.

I've used this with some success, reducing a 1 minute 30 loading time down to about 15-20 seconds. Also, it reduces your heap/perm gen requirements as well.

Check the API for the exact methods.

墨小沫ゞ 2024-10-11 00:54:25

我的第一个想法是尽可能长时间地保留知识库。除非您要根据不同的规则集创建多个知识库,并且可能的组合太多,否则请保留这些知识库。在我开发的一个应用程序中,一个知识库拥有所有规则,因此我们将其视为单例。

但是,如果这是不可能的,或者您的应用程序运行时间不是那么长,我不知道 Drools 本身是否提供了任何加快速度的方法。通过调试器运行 Drools 5.0 项目,我看到 Drools 给我的知识库是可序列化的。我想反序列化知识库比重新解析规则更快。但围绕这一点设计你的应用程序时要小心!您使用接口是有原因的,并且实现可能会在没有警告的情况下发生更改。

My first thought is to keep the knowledge base around as long as possible. Unless you are creating multiple knowledge bases from different sets of rules, and there are too many possible combinations, hang onto those knowledge bases. In one application I work on, one knowledge base has all the rules so we treat it like a singleton.

However, if that's not possible or your application is not that long-running, I don't know that Drools itself provides any ways of speeding that up. Running a Drools 5.0 project through the debugger, I see that the KnowledgeBase Drools gives me is Serializable. I imagine it would be quicker to deserialize a KnowledgeBase than to re-parse the rules. But be careful designing your application around this! You use interfaces for a reason and the implementation could change without warning.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文