Warm tip: This article is reproduced from serverfault.com, please click

SWI-Prolog in Semantic Web

发布于 2011-01-26 16:52:44

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.

Questioner
uncaught_exceptions
Viewed
0
Little Bobby Tables 2011-02-08 19:55:48

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.