Just wondering in general if anyone here has experience with Prolog, or any other language like it. It's a declarative language, based in logic.
As far as I can tell, it's basic function is to generate based on rules then answer based on matching to what has been generated-- something like brute force. It's in theory efficient (at least some say it is), but I have my doubts, and it does things like get into endless loops quite easily.
I'm using it for a linguistics course, trying to model language.
Here's an example of the syntax:
That takes the information, setting up the words. Then it sets up a sentence if it meets the conditions that the two words are a noun then a verb and the two words make up a list to form the sentence. (Concatenation is a function written for the purpose of checking whether two components add up to a certain list-- sorta like an array.)Code:word([joe],[noun]). word([jim],[noun]). word([thinks],[verb]). word([sleeps],[verb]). sentence(S) :- word(N,[noun]), word(V,[verb]), concatenation(N,V,S). concatenation([],List,List). concatenation([Head|List1],List2,[Head|List3]) :- concatenation(List1,List2,List3).
It works entirely from the command line, and it would then output basic sentences like "jim sleeps," though as a "list" (with commas and such), rather than a properly formatted string.
Here's the wikipedia information:
http://en.wikipedia.org/wiki/Prolog



Reply With Quote

It looks quite similar to Erlang!

Bookmarks