【问题标题】:Can anyone point me at a good example of pretty printing rules to "english"谁能给我指出一个很好的“英语”打印规则的例子
【发布时间】:2008-11-04 18:33:04
【问题描述】:

我有一个用户使用规则引擎构建的等价物。但是在显示规则列表时,我希望能够将每个规则“漂亮地打印”成看起来不错的东西**。在内部,当表示为字符串时,它们看起来像 s 表达式,所以想象一下:

(and (contains "foo" "foobar") (equals 4 (plus 2 2 )))

谁能指出一个在以可读方式显示规则方面做得很好的程序?

** 也需要可本地化,但我想我们会将其留作额外的功劳。

【问题讨论】:

    标签: nlp pretty-print rule-engine


    【解决方案1】:

    也许可以查看正在开发 Attempto Controlled English (ACE) 的 Attempto project。 ACE 允许您使用英语的子集编写规则。例如:

    If "foo" contains "foobar" and "foobar" does not contain "foo" then 4 = 2 + 2.
    

    ACE 解析器将此类规则转换为称为话语表示结构 (DRS) 的逻辑形式。对于上面的例子,它看起来像这样:

    []
       [A]
       predicate(A, contain, string(foo), string(foobar))-1
          NOT
          [B]
          predicate(B, contain, string(foobar), string(foo))-1
       =>
       []
       formula(int(4), =, expr(+, int(2), int(2)))-1
    

    有一个名为 DRS 语言生成器的工具可以将 DRS 转换为 ACE。对于上述 DRS,您将获得:

    If "foo" contains "foobar" and it is false that "foobar" contains "foo" then 4 = ( 2 + 2 ).
    

    在您的情况下,您必须将您的规则表示形式转换为 DRS(这应该非常简单),然后您可以直接使用 DRS 语言器。提到的工具是available under the LGPL license

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-29
      • 2013-06-06
      • 1970-01-01
      • 2012-06-24
      • 2020-09-19
      • 2011-06-09
      • 2010-10-23
      • 1970-01-01
      相关资源
      最近更新 更多