Created
November 28, 2016 19:00
-
-
Save enewe101/f5d053917abef3f038e0364130c5ec11 to your computer and use it in GitHub Desktop.
This should be in corenlp-xml-reader
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 get_constituent_tokens(constituent, recursive=True): | |
tokens = [] | |
for child in constituent['c_children']: | |
if isinstance(child, Token): | |
tokens.append(child) | |
elif recursive: | |
tokens.extend(get_constituent_tokens(child, recursive)) | |
return tokens |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment