Skip to content

Instantly share code, notes, and snippets.

@enewe101
Created November 28, 2016 19:00
Show Gist options
  • Save enewe101/f5d053917abef3f038e0364130c5ec11 to your computer and use it in GitHub Desktop.
Save enewe101/f5d053917abef3f038e0364130c5ec11 to your computer and use it in GitHub Desktop.
This should be in corenlp-xml-reader
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