percyliang / sempre

Semantic Parser with Execution
Other
828 stars 301 forks source link

ContextFn support for mixed-depth nodes? #188

Open krivard opened 5 years ago

krivard commented 5 years ago

Hi, I'm hoping to use ContextFn similarly to the anaphora rule for 'he' in the documentation, but pulling out a non-leaf logical form that apparently has children of nonuniform depth.

The context exchange looks like this:

(exchange (exchange harriet (call edu.cmu.lia.semparse.ReferenceQuery.generate 
(string OBJECT) (string pk=32)) (string OBJECT[pk=32])))

& I would take either a solution for

 (string OBJECT[pk=32])

or for

(call edu.cmu.lia.semparse.ReferenceQuery.generate (string OBJECT) (string pk=32))

The documentation suggests a rule like this would work:

(rule $CATEGORY (he) (ContextFn (depth 0) (type fb:type.text)))

...but, alas, no luck. I've also tried depth 1 and depth 2, with no success. Some digging and print statements suggest that my first preference ((string ...) is never investigated, and my second preference ((call ...) can never be selected because it has two leaf children of depth 1 and four leaf children of depth 2.

What's the intended behavior of the depth restriction -- are higher-level nodes meant to be completely symmetrical in depth, or would it be alright to replace that currentLevel == depth with currentLevel <= depth?