谁能给我指出一个关于“英语”的漂亮打印规则的好例子吗?
我已经得到了用户使用规则引擎构建的 AST 的等效项。 但是当显示规则列表时,我希望能够将每个规则“漂亮地打印”成看起来不错的**。 在内部,当表示为字符串时,它们看起来像 s 表达式,因此可以想象一下:
(and (contains "foo" "foobar") (equals 4 (plus 2 2 )))
任何人都可以向我指出一个以可读方式很好地显示规则的程序吗?
** 也需要本地化,但我想我们会把它留作额外的功劳。
I've got the equivalent of an AST that a user has built using a rule engine. But when displaying a list of the rules, I'd like to be able to "pretty print" each rule into something that looks nice**. Internally when represented as a string they look like s-expressions so imagine something like:
(and (contains "foo" "foobar") (equals 4 (plus 2 2 )))
Can anyone point me at a program that has done a good job of displaying rules in a readable fashion?
** Needs to be localizable too, but I guess we'll leave that for extra credit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许可以查看正在开发 Attempto Controlled English (ACE) 的 Attempto 项目。 ACE 允许您用英语的子集编写规则。 例如:
ACE解析器将此类规则转换为称为话语表示结构(DRS)的逻辑形式。 对于上面的例子,它看起来像这样:
有一个名为 DRSverbalizer 的工具,可以将 DRS 转换为 ACE。 对于上面的 DRS,您将得到:
在您的情况下,您必须将规则表示转换为 DRS(这应该非常简单),然后您可以直接使用 DRS 语言器。 上述工具可根据 LGPL 许可证使用。
Maybe check out the Attempto project that is developing Attempto Controlled English (ACE). ACE allows you to write rules in a subset of English. For example:
The ACE parser converts such rules into a logical form called Discourse Representation Structure (DRS). For the above example, it looks like this:
There is a tool called DRS verbalizer that converts DRSs into ACE. For the above DRS you would get:
In your case, you would have to convert your rule representation into the DRS (which should be quite straight-forward), and then you can directly use the DRS verbalizer. The mentioned tools are available under the LGPL license.