SWI-Prolog in Semantic Web
Asked Answered
I

3

25

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.

Ivanivana answered 26/1, 2011 at 16:52 Comment(6)
Java higher level than Prolog? ja!Resurgent
Funny. How do you define higher level programming. Hardware abstraction, portability .. Any languages that depends on setting rules and works directly with logic is not higher level programming . When you are teaching some one introduction to a language and he asks you, how to i Iterate and you tell him, why do you want to use iteration, why can't you define a transitive rule, its not high level programming.Ivanivana
I fear this question may a bit too specific for SO. You could try asking this on the SWI-Prolog mailing list, lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prologMerat
You are probably correct. I did send some emails and probably will post in some more specific forums.Ivanivana
I have a good deal of experience with SWI-Prolog programming, but not in the context of semantic web. Is that of any help to you?Ralston
@littlebobbytables, that should be perfectly fine. I just want to hear from people who have worked with swi prolog in a production/ commercial environment.Ivanivana
R
15

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.

Ralston answered 8/2, 2011 at 11:55 Comment(6)
Great, this is the kind of answer I was looking for. The problem I have is to do with knowledge represented in form of a model (semantic owl model, but don bother too much with detail) and existing library written in prolog that could represent this knowledge and expose this knowledge for searching and inference capabilities. ( I am going to break comment to maintain a semblance of coherency)Ivanivana
Contd: The part that, you could explain further is this statement "Keeping that in mind, you can integrate it with Java in a similar manner you integrate SQL". How can I pass data to prolog and get the result back into java.?Ivanivana
@doc_180: You have at least 3 simple options. (a) Run the SWI-Prolog HTTP server and use it as a REST web service. (b) Open a pipe to the Prolog process and send queries as text and receive results as text. (c) Use JPL swi-prolog.org/packages/jpl (haven't tried it myself, but reported to work).Ralston
Pipe query to prolog may not be the one for me. REST WS will help, but might become chatty. I did start evaluating jpl about 3 days ago and looks ok to me. Thank You.Ivanivana
Marking your answer. I tried summarizing the state of the question while marking it. Let me know if you have something to add to it.Ivanivana
+1 for giving a thorough answer to a highly specialized question.Aniseikonia
R
6

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.

Receptacle answered 16/2, 2011 at 10:5 Comment(0)
N
0
  1. For Prolog with Java : sicstus prolog
  2. You could also use CORBA
Natatory answered 23/8, 2022 at 6:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.