Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def subtree_matcher(doc):
x = ''
y = ''
# iterate through all the tokens in the input sentence
for i,tok in enumerate(doc):
# extract subject
if tok.dep_.find("subjpass") == True:
y = tok.text
# extract object
if tok.dep_.endswith("obj") == True:
x = tok.text
return x,y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment