简体   繁体   中英

nltk semantic parsing with coordination

I'm trying to build a semantic parser using python's NLTK library and following Neo-Davidsonian event representation. I've built up my grammar to include semantic features that parse correctly but I'm struggling with coordinated constituents. For example, my grammar has:

PropN[SEM=<\P.P(Mary)>] -> 'Mary'
PropN[SEM=<\P.P(John)>] -> 'John'

IV[SEM=<\x.exists e.(drinks(e) & drinker(e, x))>] -> 'drinks'

NP[SEM=?np] -> PropN[SEM=?np]
VP[SEM=?v] -> IV[SEM=?v]
S[SEM=<?subj(?vp)>] -> NP[SEM=?subj] VP[SEM=?vp]

So if the sentences is "John drinks" the result is:

exists e.(drinks(e) & drinker(e,John)).

But if I add a rule such as:

NP[SEM=<?p | ?q>] -> PropN[SEM=?p] CONJ PropN[SEM=?q]

as in "John or Mary", I end up getting this:

(\P.P(John) | \P.P(Mary))(\x.exists e.(drinks(e) & drinker(e,x)))  

As in, the NP lambdas are not being passed into the argument for the verb. I tried looking around but there's very little info on coordination in nltk semantic parsing, and even less on using it with lambdas. I know it's possible, because a classmate apparently got his to work but I'm not sure what the trick is.

Just in case people find this later, I was able to set up my rules to pass in correct lambda values for coordinated structures:

NP[SEM=<?conj(?p, ?q)>] -> N[SEM=?p] CONJ[SEM=?conj] N[SEM=?q]
CONJ[SEM=<\Q \P \x.(Q(x) | P(x))>] -> 'or'

This should work for both NPs and VPs with lambdas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM