Skip to content

Instantly share code, notes, and snippets.

@cosmozhang
Created November 30, 2015 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosmozhang/193a4aeea7bde2c6f1e8 to your computer and use it in GitHub Desktop.
Save cosmozhang/193a4aeea7bde2c6f1e8 to your computer and use it in GitHub Desktop.
NLTK stanford parser
import os
from nltk.parse import stanford
os.environ['STANFORD_PARSER'] = '/path/to/standford/jars'
os.environ['STANFORD_MODELS'] = '/path/to/standford/jars'
parser = stanford.StanfordParser(model_path="/location/of/the/englishPCFG.ser.gz")
sentences = parser.raw_parse_sents(("Hello, My name is Melroy.", "What is your name?"))
print sentences
# GUI
for line in sentences:
for sentence in line:
sentence.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment