Building a sample (micro) service in Prolog

2014-09-07

Sometimes ago I read that some components of IBM Watson were implemented in prolog . So I decided to look at it again after many years… I like Prolog, I studied prolog at Computer Science University of Milan and for my thesis I wrote code in Prolog (and Lisp). proloGraph is a simple example of howto exposing a prolog graph database to other applications,  building a REST web service. I used swi-prolog and its http library Install the prolog language (I used the fantastic Linux Debian distribution) withapt-get install swi-prologclone my git repositorygit clone https://github.com/matteoredaelli/proloGraph cd proloGraphRun it withswipl -s webserver.pl -g 'server(8765).'Open the following url with your browserhttp://localhost:8765/vertex?name=user(matteo)and you will get:``` { “prev”: [ {“from”:“user(gabriele)”, “to”:“user(matteo)”, “rel”:“follow”} ], “next”: [ {“from”:“user(matteo)”, “to”:“user(ele)”, “rel”:“follow”}, {“from”:“user(matteo)”, “to”:“user(gabriele)”, “rel”:“follow”}, {“from”:“user(matteo)”, “to”:“user(4)”, “rel”:“follow”}, {“from”:“user(matteo)”, “to”:“country(italy)”, “rel”:“lives”}, {“from”:“user(matteo)”, “to”:“hobby(running)”, “rel”:“likes”} ] }


Enter your instance's address


More posts like this

Smart investment Problem with Prolog

2024-07-14 | #programming #prolog

Below my #prolog solution for Smart investment problem. It is a sample of Linear Programming using Prolog. A client of an investment firm has $10000 available for investment. He has instructed that his money be invested in particular stocks, so that no more than $5000 is invested in any one stock but at least $1000 be invested in each stock.

Continue reading 


Stable Marriage Problem with Prolog

2024-06-07 | #programming #prolog

My #prolog solution for Stable Marriage Problem proposed by dmcommunity.org challenge Jun 2024. Given n men and n women, where each person has ranked all members of the opposite sex in order of preference, marry the men and women together such that there are no two people of opposite sex who would both rather have each other than their current partners.

Continue reading 