语义网中的 SWI-Prolog
我想听听具有使用 SWI-Prolog 语义库的实际编程经验的人的意见。
编辑:这个问题的原因是,在我采访过的许多具有 Prolog 经验的人中,大多数人他们似乎在学术项目中使用了它来进行一些人工智能编程。我想知道是否有人在生产环境中广泛使用它。因为实时可维护性、性能与完成项目以获得好成绩是不同的。
您是如何与 Java 这样的编程语言集成的?
编辑:正如答案中提到的,似乎 REST 服务或使用 SWI-Prolog 的外部接口是两个最佳选择。
你使用 prolog 库来做什么(在语义网的上下文中)?
在这里可能不会得到明确的答案。也许,这个问题属于语义溢出。我现在有了一个合理的想法,并将在更合适的论坛中继续讨论。
使用了什么开发环境? Emacs 或其 SWI-Prolog 提供的变体似乎是压倒性的答案。
我从来没有想要像 Intellij IDEA for java 这样的 IDE。毕竟我会做什么,自动完成?我理解基于规则的语言的必要性。再说一遍,我讨论开发环境的原因是为了帮助我跟踪我的规则(调试)并且也可能识别我的知识集中的异常情况。 SWI-Prolog 的图形跟踪器满足了第一个要求,但至少对我来说,它显得粗制滥造且有限。但我不相信还有别的事情。
我真的很喜欢使用 SWI-Prolog 的想法,但如果它影响生产力,我会远离它。
正如答案中提到的,Prolog 应该用于执行它擅长的事情。我一直都知道这一点,因此我对与其他编程语言的集成提出了疑问。似乎最大的生产力消耗是开发人员的质量,并且处于开发阶段。您的系统中的问题可能处于休眠状态且不易修复,但可以通过使用一组问题来检查系统的有效性来解决。
注意:当我提到答案时,我指的是@littletable 提供的答案。另外,对于对语义网络 SWI-Prolog 感兴趣的人来说,thea 看起来很有趣。
I would like to hear from people who have real world programming experience in using SWI-Prolog's semantic library.
Edit: The reason for this question is, among the many people I talked to with prolog experience, most of them seem to have used it for some AI programming in their academic projects. I wanted to know if someone have used it widely in a production environment. Because real time maintainability, performance is different from having a project done to get good grades.
How did you integrate with a programming language like Java?
Edit: As mentioned in the answer, it seems REST Services or usage of SWI-Prolog's foreign interface are the two best options.
What did you use prolog libraries for (in context of semantic web)?
Probably will not get a definite answer for this here. May be, this question belongs to semantic overflow. I have a fair idea now and will continue this discussion in more appropriate forum.
What development environment was used?
Emacs or its variant provided by SWI-Prolog seems to be the overwhelming answer.
I never wanted an IDE like Intellij IDEA for java. After all what would I do, auto complete? I understand the necessity of rule based language. Then again, the reason why I discussed development environment, is to help me trace my rule (debug ) and also probably identify anomalies in my knowledge sets. SWI-Prolog's graphical tracer takes care of the first requirement, but at least to me, it appeared shoddy and limited. But I do not believe there is anything else.
I really like the idea of using SWI-Prolog but will steer away from it, if it affects productivity.
As mentioned in the answer, Prolog should be used to perform what it is good at. I always knew this and hence my question on integration with other programming languages. It seems the biggest productivity hog is the quality of developers and is in development phase. Problems in your system might be dormant and not easily fixable, but it could be handled by using a set of questions for checking the validity of your system.
Note: when I mention answer, I mean the answer provided by @littletable. Also for people interested in SWI-Prolog for semantic web, thea looks interesting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
免责声明:我没有在商业/生产环境中使用 SWI-Prolog,我没有尝试 SWI/Java 接口(尽管在 SWI-Prolog 邮件列表上报告它工作得相当好),并且我对语义网。
也就是说,我确实使用 SWI-Prolog 编写了一个大型且重要的项目,它不是一个玩具应用程序 - 我需要它工作才能完成我的研究。因此,我有一些凭证来回答这个问题,即使不是所有必需的凭证。
在大型项目的上下文中,最好将 Prolog 视为用于编写搜索例程的特定于域的语言 - 与 SQL 和存储不同。 Prolog 在一件事上做得非常好,那就是它解决了搜索问题。如果您的问题可以缩小到在给定一组事实和规则的情况下找到对一组变量的有效分配,那么 Prolog 是您的首选武器:除了调整之外,您不必担心编码中的其他任何事情查询和规则。它的运行速度也相当快,特别是在编译谓词时。 Prolog 通常很慢,并不是因为它本质上很慢,而是因为它在很大的搜索空间上运行搜索例程。
记住这一点,您可以将其与 Java 集成,就像集成 SQL 一样:Prolog 负责解决搜索问题。它存储永久数据和规则,并运行查询。 Java 应用程序负责处理其他事情。
开发环境是 Prolog 的软肋。您不会得到一个精美的 IDE - 只是因为很少有什么值得花哨的。 Prolog 程序很少有完整的编译时信息,因此您不会获得完美的自动完成功能。我只是使用 Emacs,Prolog shell 始终打开。对于大多数事情,Prolog 文本跟踪器/调试器就可以解决问题。 SWI 带有它自己的图形调试器,但我还没有尝试过。
Prolog 有几个鲜为人知的优点:内置的解析框架(DCG 规则)、出色的宏系统(术语扩展)和元谓词(call、findall 等)。如果您知道如何使用它们,那么它们就是您套牌中真正的王牌。
总结一下:Prolog 会提高还是损害生产力?这取决于当前阻碍您生产力的因素。如果您浪费太多时间思考如何在 Java 中实现知识表示和搜索例程 - 只需使用 Prolog;这并不是说您可以实现自己的红黑树而不是使用 SQL。如果您正在寻找软实时性能和破坏性的 IDE - 请尝试其他方法。
Disclaimer: I did not use SWI-Prolog in a commercial/production environment, I did not try the SWI/Java interface (although it was reported on the SWI-Prolog mailing list to work reasonably well), and I have no interest in the semantic web.
That said, I did write a large and non-trivial project using SWI-Prolog, and it wasn't a toy application - I needed it to work in order to finish my research. Therefore I have some credentials for answering this question, even if not all of the required ones.
In the context of a large project, it is best to treat Prolog as a domain-specific language for writing search routines - Not unlike SQL and storage. Prolog does one thing extremely well, and that it solving search problems. If your problem can be narrowed down to finding a valid assignment to a set of variables given a set of facts and rules, Prolog is your weapon-of-choice: You won't have to worry about anything else in your coding other than tweaking the queries and rules. It will also run reasonably fast, especially if you compile the predicates. Prolog is often slow not because it is inherently slow, but because it runs search routines over a large search space.
Keeping that in mind, you can integrate it with Java in a similar manner you integrate SQL: Prolog takes care about solving the search. It stores the permanent data and the rules, and run the queries. The Java app takes care of anything else.
Development environments are a bit of a soft-spot for Prolog. You won't get a fancy IDE - Simply because there are very few things to be fancy about. Prolog programs rarely have full compile-time information, so you won't get perfect auto-completion. I simply used Emacs, with the Prolog shell always open. For most things, the Prolog textual tracer/debugger will do the trick. SWI comes with its-own graphical debugger, but I haven't tried it.
Prolog has several rarely-known advantages: A built-in parsing framework (DCG rules), a great macros system (term expansion), and meta-predicates (call, findall, etc.). If you know how to use them, these are real aces in your deck.
To summarize: Does Prolog boosts or damages productivity? That depends on what currently blocks your productivity. If you waste too much time wondering how to implement knowledge representation and search routines in Java - Just use Prolog; It's not as if you implement your-own red-black trees instead of using SQL. If you're looking for soft-realtime performance and a spoiling IDE - Try something else.
我也没有真正在生产环境中使用它,但我将它集成到基于Java/Eclipse的Bioclipse工作台中,作为我论文工作的一部分,用于现实场景。此外,论文工作主要集中于测试 Bioclipse 中 prolog 集成的性能和可用性。
我将简短回答您在下面提出的问题,但对于任何感兴趣的人,最多的信息可以在我的论文报告中找到,名为 "SWI-Prolog 作为 Bioclipse 中语义查询的语义 Web 工具:集成和性能基准测试",以及我的相关标记 博客文章。源代码可在 github 存储库中获取。
如何与 Java 这样的编程语言集成?
我使用了 JPL Java Prolog 接口
您使用 prolog 库做什么(在语义 Web 的上下文中)?
我用它对大约 60000 个 RDF 数据库进行一些模式匹配NMR 谱,包含不同高度的峰。我用它来测试 SWI-Prolog 在此操作中的性能,并与其他语义 Web 工具(例如 Pellet 和 Jena(基于 Java))进行比较。 (顺便说一句,SWI-Prolog 的性能远远优于这两个工具)。
使用了什么开发环境?
Eclipse RCP
我真的很喜欢使用 swi prolog 的想法,但如果它影响生产力,我会避开它。
我的经验是,除了提高了某些问题的生产力,某些操作的性能也远远优于用传统编程语言编写的工具。
I did not really use it in a production environment either, but I integrated it into the Java/Eclipse based Bioclipse workbench, to be used in real-world scenarios, as part of my thesis work. Also, the thesis work focused much on testing the performance and usability of the prolog integration in Bioclipse.
I will give short answers to the questions you asked below, but for anyone interested, the most information can be found in my thesis report named "SWI-Prolog as a Semantic Web Tool for semantic querying in Bioclipse: Integration and performance benchmarking", as well as in my relevantly tagged blog posts. The source code is available in a github repo.
How did you integrate with a programming language like Java?
I used the the JPL Java Prolog interface
What did you use prolog libraries for (in context of semantic web)?
I used it to do some pattern matching against an RDF database of some 60000 NMR spectra, containing peaks of distinct heights. I used this to test the performance of SWI-Prolog for this operation, compared to other Semantic Web tools such as Pellet and Jena (Java based). (BTW, SWI-Prolog by far outperformed both of these tools).
What development environment was used?
Eclipse RCP
I really like the idea of using swi prolog but will steer away from it, if it affects productivity.
My experience is that in addition to increased productivity for certain problems, the performance for certain operations is also far better than tools written in conventional programming languages.