Last active
September 24, 2019 06:23
-
-
Save prateekjoshi565/23bdd8f96c997d05ea0d009bb751b207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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