9 ms·
Natural Language Processing with Prolog in the IBM Watson System (2011)
- triska 4y agoProlog is brilliantly useful for text processing and reasoning about strings, mostly due to its built-in grammar formalism called Definite Clause Grammars (DCGs). In fact, Prolog originates from Q-systems which were specifically designed to process language via grammar rules: https://en.wikipedia.org/wiki/Q-systems https://en.wikipedia.org/wiki/Q-systems The "Q" stands for Québec, where Alain Colmerauer developed this formalism which eventually led to Prolog. A recently released documentary talks a bit about these developments: https://youtu.be/74Ig_QKndvE https://youtu.be/74Ig_QKndvE It is interesting that the very first Prolog systems, Prolog 0 and Marseille Prolog, represented strings as lists of characters, then the Edinburgh tradition used lists of codes (in the implementation defined encoding), and all Prolog systems that have become available in the last 5 years (Scryer Prolog, Tau Prolog, Trealla Prolog and ichiban/prolog) are again using lists of characters to make string processing as convenient and readable as originally intended. For example, we can use definite clause grammars in Scryer Prolog to find occurrences of the same character twice in immediate succession in a string: ?- phrase((...,[C,C],...), "Hello, world!"). C = l ; false. In this string, the character 'l' is the only such letter.
- funstuff007 4y ago> https://youtu.be/74Ig_QKndvE https://youtu.be/74Ig_QKndvE Bon jour, the doc is en Francais. However, it does have legit subtitles (i.e. not auto-generated).
- historia_novae 4y agoThanks, that was an interesting watch.
- YeGoblynQueenne 4y agoTo be more precise, most Prologs before the last 5 years have built-in predicates that break _atoms_ up into either character codes, or characters. "String" as a datatype is the novelty of the new generation of Prologs. For instance, here's Sicstus | ?- atom_codes('abcd', Cs). Cs = [97,98,99,100] ? ; no | ?- atom_chars('abcd', Cs). Cs = [a,b,c,d] ? ; no | ?- Personally, I'm kind of ambivalent about this new direction. "String" is a programming language concept, but not a FOL concept. "Atom" is a FOL concept- but Prolog mangles the clean and tidy FOL (and Logic Programming) nomenclature and calls "atom" everything that should really be called a _constant_, and calls what should really be called an "atom", a "term". Then it's all downhill from there. The ideal for me would be to redress the wrong of confusing terminological swaps in Prolog jargon (atom--> constant, term--> bloody everything, predicate--> program, functor--> symbol, etc) and leave the details of the implementation (whether to represent constants as lists of characters or codes, and whether to define built-ins that operate on them) to the implementor. For me, Prolog's Logic Programming roots are the only thing that makes sense and helps understand Prolog. The turn towards programming language semantics and sometimes database semantics, has only served to make a mess of things. I blame it for the notorious difficulty that most programmers face in trying to pick up Prolog, which is seriously incommensurate to the brilliant simplicity of FOL and LP syntax and semantics.
- dallasg3 4y agoI didn't know FOL stood for First-Order Logic.
- YeGoblynQueenne 4y agoOh, sorry, you're absolutely right. I should have explained the acronym before using it.
- jhgb 4y ago> "Atom" is a FOL concept- but Prolog mangles the clean and tidy FOL (and Logic Programming) nomenclature and calls "atom" everything that should really be called a _constant_, and calls what should really be called an "atom", a "term". It almost seems like they got all this confusion from badly copying Lisp. What you refer to above is clearly ancient (pre-Common) Lisp's EXPLODE and IMPLODE operators (https://www.cs.cmu.edu/Groups/AI/html/faqs/lang/lisp/part2/faq-doc-3.html https://www.cs.cmu.edu/Groups/AI/html/faqs/lang/lisp/part2/f...). Of course Lisp's symbols are Prolog's atoms, and Lisp's atoms are Prolog's terms.
- YeGoblynQueenne 4y agoI remember reading and re-reading that article back when it first appeared on the 'net, right after I graduated from CompSci with a big crush on Prolog, paired to gigantic gaps in my understanding of it (and of Logic Programming in general). The article looked... not enough. I got a general idea of how Prolog was used in Watson, but not clear enough that I could easily reproduce it myself. Or so I thought back then. Reading it again now, it's clear to me that they used Prolog to implement the rule-based part of their system, whose function was, essentially, to map from an initial parse of a Jeopardy qustion to a semantic representation of the question, then find an answer for it. Similar to what Triska points out in another comment in this thread, this is Prolog's bread and butter and the kind of thing that modern AI approaches can still not do very well, or at all. The downside of course is that they had to encode all those rules in Prolog by hand. Which is not strictly necessary thanks to Inductive Logic Programming approaches, that can learn Prolog programs from data, either on their own, or in an interactive session, collaborating with a human programmer. I hear that IBM now have a dedicated ILP team who seem to be working on problems like that. Let's hope that the Watson debacle doesn't drag the whole thing down with it.
- daviddaviddavid 4y agoRegarding modern AI approaches not being great at what Prolog does, I'm curious if this will ever translate into an uptick in job postings for Prolog (or, at least, rule-based/declarative) jobs. One would expect hybrid systems in which the old school approach played some significant role, but I haven't noticed that happening in the market.