Natural Language Toolkit

...software, data sets and tutorials for natural language processing...

Getting Started

 

From NLTK

Jump to: navigation, search

Once you have Installation installed Python and NLTK, you can get started as follows.

Contents

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.5 -> IDLE
Mac
Finder -> Applications -> MacPython 2.5 -> IDLE
Unix
$ idle

Hello World!

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

>>> print "Hello World!"

Running NLTK's Graphical Demonstrations

Try the following commands. They will produce displays like the ones shown in the Screenshots page

>>> import nltk
>>> nltk.draw.rdparser.demo()
>>> nltk.draw.srparser.demo()
>>> nltk.draw.chart.demo()
>>> nltk.draw.tree.demo()

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.tag.ngram.demo()
>>> nltk.wordnet.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).

Personal tools