有没有适用于Go的规则引擎/推理引擎?

huangapple go评论85阅读模式
英文:

Is there any Rules Engine/Inference Engine for Go

问题

我们想使用Go来实现我们的业务逻辑,但是我们找不到任何好的Go规则引擎/推理引擎的实现。有人有任何经验或建议吗?

英文:

We want to implement our business logic using Go, but we cannot find any good implementation of rules engine/inference engine for Go. Does anyone have any experience or suggestions?

答案1

得分: 3

有一个项目旨在用Go实现一个ISO Prolog编译器:GoLog。我还没有测试过它,但是考虑到它实现了一些基本的Prolog,它应该是一个相当有能力的基于规则的推理引擎。

此外,在godoc.org上搜索“rule”也会得到一堆包:

  • godoc.org/?q=rule
英文:

There is a project that aims to implement an ISO Prolog compiler in Go:

I haven't tested it, but given that it implements some basic Prolog, that should be quite a capable rule-based reasoning engine, AFAIS.

Otherwise, a search for "rule" over at godoc.org also yields a bunch of packages:

答案2

得分: 1

我所了解的类似这样的最好例子是在许多标准库中采用的“表驱动”单元测试方法。例如,fmttests

除此之外,Go是一种强大而表达力强的语言。你实际上需要什么?在Go中有许多状态机实现的例子,还有一些具有声明性JSON配置的Web框架。

如果你指的是适当的逻辑编程,目前还没有流行的Go库。

英文:

The best example of something like this to my knowledge is the 'table-driven' approach to unit tests taken in much of the standard library. For example, the fmttests.

Beyond that, Go is a powerful, expressive language. What do you actually need? There are a number of examples of state machine implementations in Go, and a number of web frameworks with declarative JSON configuration.

If you mean proper logic programming, there's no popular Go library for it yet.

答案3

得分: 1

如果你熟悉JBoss Drools,现在在Golang中有类似的东西。
看看这个https://github.com/newm4n/grool

它有类似于Drools DRL的DSL,称为GRL。

规则减速“当测试车减速时,我们继续降低速度。”优先级10 {
    当
        TestCar.SpeedUp == false && TestCar.Speed > 0
    然后
        TestCar.Speed = TestCar.Speed - TestCar.SpeedIncrement;
        DistanceRecord.TotalDistance = DistanceRecord.TotalDistance + TestCar.Speed;
}
英文:

If you're familiar with JBoss Drools, now there's something similar in Golang.
Check this out https://github.com/newm4n/grool

It has DSL similar to Drools DRL, called GRL.

rule SlowDown "When testcar is slowing down we keep decreasing the speed." salience 10  {
    when
        TestCar.SpeedUp == false && TestCar.Speed > 0
    then
        TestCar.Speed = TestCar.Speed - TestCar.SpeedIncrement;
		DistanceRecord.TotalDistance = DistanceRecord.TotalDistance + TestCar.Speed;
}

答案4

得分: 0

请查看 https://github.com/antonmedv/expr

它可以解析以下表达式:

# 如果用户组在以下列表中,则获取特殊价格
user.Group in ["good_customers", "collaborator"]

# 当文章评论数大于100且文章分类不在以下列表中时,将文章推广到主页
len(article.Comments) > 100 and article.Category not in ["misc"]

# 当产品库存小于15时发送警报
product.Stock < 15

对它们进行类型检查并进行评估。

此外,代码质量非常好: 有没有适用于Go的规则引擎/推理引擎? 有没有适用于Go的规则引擎/推理引擎? 有没有适用于Go的规则引擎/推理引擎?

英文:

Take a look at https://github.com/antonmedv/expr

It can parse next expressions:

# Get the special price if
user.Group in [&quot;good_customers&quot;, &quot;collaborator&quot;]

# Promote article to the homepage when
len(article.Comments) &gt; 100 and article.Category not in [&quot;misc&quot;]

# Send an alert when
product.Stock &lt; 15

Type check them and evaluate.

Also code really good: 有没有适用于Go的规则引擎/推理引擎? 有没有适用于Go的规则引擎/推理引擎? 有没有适用于Go的规则引擎/推理引擎?

huangapple
  • 本文由 发表于 2013年3月28日 03:53:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/15668174.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定