DCG semantic parser for English

Bratko’s textbook contains a semantic parser for a very tiny fragment of English. It can parse sentences like

every woman that admires a man that paints likes monet.

into

∀x: woman(x) ∧ (∃y: man(y) ∧ paints(y) ∧ admires(x, y) → likes(x, monet))

which is fun (although incorrect, in this case). I wonder what the state of the art is for these kinds of parsers? Anything I can play with in SWI Prolog?

1 Like

Well, surely not ‘state-of-the-art’, but I suggest to take a look at chat80.

For something playable and more advanced, I suggest to evaluate Attempto.

The post Looking for SHRDLU Prolog clone with working code has some suggestions.

Yes, the pack is the way to go.
Thanks for pointing out.

Also online: SWISH -- SWI-Prolog for SHaring

There was quite a bit of work on this in the 1980s and 1990s. Two projects I know of (that also used Prolog) were “Lilog” at IBM Germany (there’s a Springer book on that) and another at IBM Sweden, but I can’t find the references to the latter (it was based on someone’s PhD thesis, I think). I’ll try to find out more about this, but no promises.

Other places to start looking:
Prolog implementation of machine translation: Michael McCord
Syllog: Adrian Walker
Logic grammars: Abramson & Dahl
Common Logic Controlled English: John Sowa
Attempto Controlled English: Norbert Fuchs

1 Like

A bit ashamed to ask… but what is incorrect in that sentence ?

“a man” is ambiguous and can mean “there exists”, as in, “A man is in my garage”, or “for any”, as in “A man needs regular sleep”. In this particular case, a universal quantifier makes more sense, but Bratko’s mini-grammar interprets “a” only as an existential one.

Thanks, everyone, for the replies. I was hoping to find basically a bigger version of Bratko’s approach: something that just spews out multiple interpretations instead of prohibiting ambiguities.

Sorry I don’t have a copy of Bratko available, but probably the technique he applied should derive from the formalization (or better, implementation in Prolog) of Montague approach, popularized from Pereira Schieber in Prolog and Natural-Language Analysis (I have the Italian edition). In this book, they keep a pragmatical approach wrt (unavoidable) syntactical ambiguity, and show how to generate every possible reading out of a set of qualified statements. Maybe chat80 will use something similar…

1 Like

There is also quite extensive study on semantic representation of natural language for the purpose of inferencing by Blackburn and Bos here (folder with files). (all examples are in Prolog).

I am very glad to see this comment. In fact, I have a cgi page on Montague’s PTQ (sorry only in Japanese.)

http://web.sfc.keio.ac.jp/~mukai/cgitest/ptq.html

You will find some famous sample sentences in PTQ.

[john, walk]
[every, unicorn, seek, john]
...

I wrote originally as offline prolog codes in SICStus at that time more than 20 years ago, and revised it from time to time so as to work on latest SWI-Prolog. Although time has passed since I stopped, which is enough for me to be unfamiliar with recent states of computational semantics, still I keep several ideas to try. For example, ZDD for PTQ like sematics. In PTQ, an individual is interpreted as a bundle of properties (a proper filter, or similar). I am wondering if
ZDD technology opens a direct way to implement such huge computational models on computers assuming that possible worlds are similar to each other with rich sharing structues. Anyway I do not want to be taken seriously on this, but just in case you are interested.

1 Like

Interesting. It reminds me of donkey sentence in DRT theory:

If Pedro owns a donky he beats it.
1 Like

This might interest you: Interfacing a Natural Language Front-End to a Relational Database
by Ioannis Androutsopoulos
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.30.6755&rep=rep1&type=pdf
It references a few other systems, including IBM’s LanguageAccess (which was written in Prolog).

1 Like

(sorry only in Japanese.)

Just to say- Google translate seems to do a phenomenal job of translating your page into English. [Your work looks extremely interesting to this amateur prolog and NLP enthusiast.]

Hello,

answering a bit late, not sure if you are still working on that topic…

I don’t think DCG is flexible enough for natural language parsing, and there was a lot of money burned in such projects in the 80th, 90th using Lisp and Prolog with finally not satisfying outcomes.

That sayd: I wrote some Esperanto word analyzer with some decent outcome to check derivations against a dictionary. It uses a grammar which defines which combinations are allowed and keep track of the language atributes. The grammar is transformed to Prolog predicates using term_expansion. The algorithm is basically splitting the inpu at various places and trying to recombine it using the grammar rules.

The grammar is here: voko-akrido/vorto_gra.pl at 5f3d0a4408a96ef96085bc03e5bdeaaf5b20db2c · revuloj/voko-akrido · GitHub

And the transformation is there: voko-akrido/regul_trf.pl at 5f3d0a4408a96ef96085bc03e5bdeaaf5b20db2c · revuloj/voko-akrido · GitHub

But it is work for numourous months and I’m not sure about language phrase analysis. I could imagine that there is much more variety and ambiguity involved in englisch phrases.

There is a guy in Denmark who worked several years on creating grammar based language analysers for several languages based on Constraint Grammar CG3 open source framework, and he used ten times more rules for english than Esperanto. This is one of his websites: https://gramtrans.com/ if you like to check this out.

Kind regards,
Wolfram.