Created
November 30, 2015 02:44
-
-
Save cosmozhang/193a4aeea7bde2c6f1e8 to your computer and use it in GitHub Desktop.
NLTK stanford parser
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
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