@@ -40,7 +40,6 @@ def complete(self, tokens, qtype):
4040 prev_node = prev_node .prev
4141 ret .append (prev_node .label )
4242
43- print ret
4443 while cur_node .label not in smap and len (cur_node ) > 0 :
4544 ret .append (cur_node .label )
4645 cur_node = cur_node [0 ][1 ]
@@ -113,7 +112,6 @@ def get_root_word(word):
113112def get_node (label ):
114113 if label not in smap :
115114 smap [label ] = Node (label )
116- smap [label ].set ('->' , Node (label + "'s properties" ))
117115 return smap [label ]
118116
119117def flatten_tree (tree ):
@@ -266,8 +264,10 @@ def describe(tree):
266264 action_node .set ('.' , obj )
267265
268266 if matches ('( VP ( VB/VBZ/VBP/VPZ/VBD/VBG/VBN ) ( NP ) ( PP ) )' , tree ):
269- prop , prop_node = describe (tree [2 ])
270- action_node .set (prop , prop_node )
267+ # Assume rest is PP
268+ for pp_node in tree [2 :]:
269+ prop , prop_node = describe (pp_node )
270+ action_node .set (prop , prop_node )
271271
272272 return action , action_node
273273
@@ -348,32 +348,19 @@ def answer(tree):
348348 return "Nothing"
349349 return ',' .join (objs )
350350
351- if matches ("""
352- ( SBARQ
353- ( WHNP ( . ) ( NN ) )
354- ( SQ ( VBP ) ( NP ) ) )""" , tree ):
355- # Ex: What color are blueberries
356- qtype = get_word (tree [0 ][0 ])
357- propy = get_word (tree [0 ][1 ])
358- action = get_root_word (get_word (tree [1 ][0 ]))
359-
360- print "%s %s %s ____" % (subject , propy , action )
361-
362- return get_node (subject ).get ('->' ).get (propy ).get (action ).label
363-
364351 print "ERROR answering"
365352
366353
367354line = raw_input ("Enter line: " )
368355
369356while line != 'stop' :
370357 sent = list (parser .raw_parse (line ))[0 ]
371- # print sent
358+ #print sent
372359 if sent [0 ].label () == "SBARQ" :
373360 print answer (sent )
374361 else :
375362 describe (sent )
376- # print smap
363+ #print smap
377364 line = raw_input ("Enter line: " )
378365
379366"""
0 commit comments