Lambda-Calculus Representation in NLTK CCG

1.4k Views Asked by At

I am trying to implement a probabilistic ccg with lambda-calculus features.

Basically i want to do the following code:

>> lex = parseLexicon(r'''
 :- S,NP
 He => NP {sem=\x.he(x)} [1.0]
 Walks => S\NP {sem=\X. walk(X)} [1.0]
 There => S\S {sem=\x . there(x)} [1.0]
 ''')
>> parser = CCGChartParser(lex)
>> all_parses = parser.nbest_parse(“He walks 
there”.split(),n=100)
>> for parse in all_parses: 
 printCCGDerivation(parse)

but existing CCG implementation of NLTK does not support {sem=\x.he(x)} [1.0] kinds of semantic parts in lexicon.

Are there Any other CCG implementations that can handle this? Or can i represent this inside of NLTK?

3

There are 3 best solutions below

2
Tanin On BEST ANSWER

NLTK CCG recently supports semantics predicate (Lambda-Calculus representation) computation. Please see the tests here: https://github.com/nltk/nltk/blob/develop/nltk/test/ccg_semantics.doctest

The probabilistic parsing for CCG is on the horizon: https://github.com/nltk/nltk/issues/1356

1
Rob Ellis On

Unfortunately no, this does not exist yet. I too have been looking at this space. It seems to be in the works mentioned here on their wiki - Semantic-Parsing

If you are interested in other languages / frameworks, take a peek at Semantic Parsing with Execution, Stanford or The University of Washington Semantic Parsing Framework.

If you want to build something from the ground up, you might want to obtain the CCGBank or revive C&C Tools.

Most of the above is in Java, but I have seen attempts to parse the C&C Marked file in Python.

I personally would like to see CCG come to Node.js.

0
CSaki On

If you don't mind switching to Common LISP, there is a ccg tool (CCGlab) developed by Cem Bozsahin. It also has PCCG training. https://github.com/bozsahin/ccglab