Skip to content

Instantly share code, notes, and snippets.

@neubig
Created October 18, 2011 07:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save neubig/1294794 to your computer and use it in GitHub Desktop.
A file to print parse trees from standard input using NLTK
#!/usr/bin/python
from nltk.tree import Tree
import sys
# A program to display parse trees (in Penn treebank format) with NLTK
#
# To install NLTK on ubuntu: sudo apt-get install python-nltk
for line in sys.stdin:
t = Tree.parse(line)
t.draw()
@mahmud2011
Copy link

Tree has no attribute 'parse'.

@alphadl
Copy link

alphadl commented Nov 15, 2019

@mhy13 @neubig Maybe Tree.parse() should be Tree.fromstring(line)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment