How to use Stanford Parser in NLTK using Python

Note that this answer applies to NLTK v 3.0, and not to more recent versions. Sure, try the following in Python: Output: [Tree(‘ROOT’, [Tree(‘S’, [Tree(‘INTJ’, [Tree(‘UH’, [‘Hello’])]), Tree(‘,’, [‘,’]), Tree(‘NP’, [Tree(‘PRP$’, [‘My’]), Tree(‘NN’, [‘name’])]), Tree(‘VP’, [Tree(‘VBZ’, [‘is’]), Tree(‘ADJP’, [Tree(‘JJ’, [‘Melroy’])])]), Tree(‘.’, [‘.’])])]), Tree(‘ROOT’, [Tree(‘SBARQ’, [Tree(‘WHNP’, [Tree(‘WP’, [‘What’])]), Tree(‘SQ’, [Tree(‘VBZ’, [‘is’]), Tree(‘NP’, [Tree(‘PRP$’, [‘your’]), Tree(‘NN’, [‘name’])])]), … Read more

Spell Checker for Python

I’m fairly new to Python and NLTK. I am busy with an application that can perform spell checks (replaces an incorrectly spelled word with the correct one). I’m currently using the Enchant library on Python 2.7, PyEnchant and the NLTK library. The code below is a class that handles the correction/replacement. I have written a … Read more

What is the difference between lemmatization vs stemming?

Short and dense: http://nlp.stanford.edu/IR-book/html/htmledition/stemming-and-lemmatization-1.html The goal of both stemming and lemmatization is to reduce inflectional forms and sometimes derivationally related forms of a word to a common base form. However, the two words differ in their flavor. Stemming usually refers to a crude heuristic process that chops off the ends of words in the hope of … Read more

Python can’t find module NLTK

On OS X you could have multiple installation of Python, so investigate it first: All within /usr/bin are built-in and all other in /usr/local/bin are external installed by Homebrew or some other package manager. If you’re using pip or pip3 from /usr/local, then you’ve to use the same Python instance, otherwise they’re different instances. Just install it via pip: or for Python 3: then run … Read more

n-grams in python, four, five, six grams?

Great native python based answers given by other users. But here’s the nltk approach (just in case, the OP gets penalized for reinventing what’s already existing in the nltk library). There is an ngram module that people seldom use in nltk. It’s not because it’s hard to read ngrams, but training a model base on ngrams where n > 3 will result … Read more