tags:

views:

51

answers:

1

how can i edit and run the python nltk program

+2  A: 

nltk is not a program (in the sense of something that you are intended to execute) but a library. You need to import the particular modules that you need and then call their functions, or construct their objects, or whatever you want to do.

This article has some examples.

Notice the first two lines of the first example:

>>> from nltk.tokenizer import *
>>> t = Token(TEXT='This is my first test sentence')

The first line indicates that he is importing all of the definitions in the module nltk.tokenizer - this includes the Token class. In the next line, he is able to instantiate a Token object (something he would not be able to do without the import statement).

nltk is a very large library with many modules encompassing different types of natural language processing functionality. The first thing to do would be to figure out which specific functionality you would like to take advantage up, and then look it up in the documentation.

danben