def calc(param):
p = ["He", "he", "Him", "him", "She", "she", "Her",
"her", "It", "it", "They", "they"]
r = ["Himself", "himself", "Herself", "herself",
"Itself", "itself", "Themselves", "themselves"]
fname = param[1]
pro = param[2]
with open(fname) as f:
sents = f.readlines()
trees = [Tree.fromstring(s) for s in sents]
pos = get_pos(trees[-1], pro)
pos = pos[:-1]
if pro in p:
tree, pos = hobbs(trees, pos)
#for t in trees:
# print t, '\n'
#print "Proposed antecedent for '"+pro+"':", tree[pos]
return tree, tree[pos]
elif pro in r:
tree, pos = resolve_reflexive(trees, pos)
#for t in trees:
# print t, '\n'
#print "Proposed antecedent for '"+pro+"':", tree[pos]
return tree, tree[pos]
评论列表
文章目录