Software License

Feedback

This site is maintained by Steven Bird.

Getting Started

The first step is to download and install NLTK.

Running Python

The simplest way to run Python is via IDLE, the Integrated Development Interface. It opens up a window and you can enter commands at the >>> prompt. You can also open up an editor with File -> New Window and type in a program, then run it using Run -> Run Module. Save your program to a file with a .py extension.

Windows
Start -> All Programs -> Python 2.6 -> IDLE
Mac
Finder -> Applications -> MacPython 2.6 -> IDLE
Unix
$ idle

Check that the Python interpreter is listening by typing the following command at the prompt. It should print Monty Python!

>>> print "Monty Python!"
Check that NLTK is installed by typing "import nltk" at the prompt.
Chapter 1 of the NLTK book suggests dozens of things to try.

Running NLTK's Graphical Demonstrations


Chart Parser nltk.app.chart()
 Shift-Reduce Parser nltk.app.srparser()


Recursive Descent Parser
nltk.app.rdparser()

 Parse Trees nltk.app.tree()
 POS Concordance nltk.app.concordance()

Chunk Parser
nltk.app.chunkparser()


Other Demonstrations

Most NLTK modules include demonstration code. Here are some examples involving tokenizing, stemming, and tagging:

>>> import nltk
>>> nltk.stem.porter.demo()
>>> nltk.stem.lancaster.demo()
>>> nltk.probability.demo()

Here are some more examples, involving parsing and semantic interpretation:

>>> import nltk
>>> nltk.chunk.regexp.demo()
>>> nltk.parse.chart.demo()
>>> nltk.sem.evaluate.demo()
>>> nltk.sem.logic.demo()

Online Documentation

You can ask for help on any Python or NLTK object using the built-in help facility, e.g. help(list), help(nltk.parse).