# NLTK: The Natural Language Toolkit

Single Python toolkit replaces multi-language setups in an intro computational linguistics course

Edward Loper, Steven Bird · arXiv · 2002-5-17

- **Problem** Intro computational linguistics courses use several languages for assignments and projects. Students spend much of the course learning those languages instead of the subject itself.
- **Method** NLTK is one Python toolkit whose modules share data structures and interfaces. Students work in a single language and extend the same building blocks for projects and demos.
- **Results** The authors report that CIS-530 students liked starting interesting projects from the outset with NLTK. The evidence is observational, with no quantitative measure.

## Why multi-language practical work stalls

Teachers of an introductory computational linguistics course usually have to set up a practical programming component for assignments and projects. The common workaround is to use several languages, each with the native data structures that suit one task. A course might lean on Prolog for parsing and Perl for corpus processing, with a finite-state toolkit for morphology, so the teacher avoids building much software.

The cost is that a large share of such a course goes to teaching the languages themselves.

Projects make this worse, because many real projects span several domains and force every language to be bridged. A parsing project on a morphologically rich language needs Perl for string handling, a finite-state tool for morphology and Prolog for parsing. The authors judged these overheads and shortcomings serious enough to call for a fresh approach.

Teaching also needs demonstrations, since an instructor often wants to show the state of a chart parser or step through a finite-state machine. Because such demonstrations are hard to set up, many instructors skip live demos and keep lectures purely theoretical. Students then meet the practical problems alone or in office hours, which is less efficient.

## One Python toolkit instead of many languages

The key idea is to replace the mix of languages with one toolkit whose modules share data structures and interfaces. Students then work in a single language, and every project and demo draws on the same building blocks. The authors expected this to cut the glue work that multi-language courses need.

Python was chosen against a few explicit requirements. The language needed a shallow learning curve, so novices get quick results, and it needed fast prototyping without a compile step. Python also meets the wish for structured, object-oriented code without the weight of C++. The authors describe Python code as readable enough to be called executable pseudocode.

Python also offers an interface to the Tk graphics toolkit, so writing graphical interfaces is straightforward. These choices are stated criteria, not measured outcomes.

## Design criteria and module layout

The authors ranked their design criteria by importance, and ease of use came first. Their reasoning was that the more time students spend learning the toolkit, the less useful it becomes. Consistency, extensibility and documentation follow, with simplicity and modularity completing the list.

Simplicity means the toolkit should expose the complexity of NLP rather than hide it. Each class should be simple enough for a student to implement by the end of an introductory course. Modularity lets a student finish one project with a small part of the toolkit and learn the rest over the course.

The authors deliberately left comprehensiveness, efficiency and cleverness out of the goals. Efficiency only needs to be good enough for students to perform real tasks.

Core modules cover tokens, trees and probability distributions. The parsing modules include parser, chunkparser, srparser, chartparser, pcfgparser and rechunkparser. The tagger and fsa modules handle tagging and finite state automata.

Type checking is explicit, so it checks that functions receive valid arguments and cuts debugging time. Because it runs explicitly, it can slow the toolkit, but it can be switched off with no performance penalty.

The classifier module defines a standard interface, with naivebayes and maxent as its implementations. The maxent model is trained with Generalized Iterative Scaling or Improved Iterative Scaling. The classifier.feature module gives one encoding, so students can compare algorithms on identical feature sets.

## Chunk rules as a student assignment

The assignment asks students to find base noun phrase chunks by writing a cascade of transformational chunking rules. Each rule is a regular-expression pattern over part-of-speech tags, and the rechunkparser module supplies several rule types. For example, ChunkRule('\<NN.\*\>') builds chunks from runs of consecutive nouns.

ChinkRule('\<VB.\>') removes verbs from existing chunks, while SplitRule('\<NN\>', '\<DT\>') breaks a chunk that holds a singular noun followed by a determiner. MergeRule('\<JJ\>', '\<JJ\>') joins two adjacent chunks when the first ends and the second starts with adjectives.

The tutorial supplies the surrounding code, which loads tagged text, makes an unchunked copy, applies the rules and scores the output. So students write only the rule set, and their goal is the rule set with the best coverage.

One student built a cascade that combined several rule types, starting with a ChunkRule over determiner, noun, verb and noun patterns. Another used a brute-force statistical approach: the student counted how often each tag fell inside a noun phrase and chunked any tag sequence that did so more than 50% of the time. A third built one chunk over the whole text and then excised everything that did not belong.

## Chart parsing shown step by step

Chart parsing records hypotheses about syntactic constituents as edges on a chart. A set of rules decides when new edges can be added, and that rule set sets the parser's overall behaviour, such as top-down or bottom-up.

The chart parsing tool demonstrates one sentence with a given grammar and lexicon. Its window has three sections: the chart at the bottom, the sentence in the middle and the partial tree for the selected edge at the top. Buttons along the bottom step the algorithm forward.

The tool explains the chart data structure, the individual rules and how the rules combine into a complete parse. Lecturers can preload a list of charts and reset to any of them at any time, which cuts setup time in lecture.

At each step the user chooses the rule or strategy to apply, so top-down and bottom-up choices can be mixed. The user also picks which edge a rule applies to, which gives fine-grained control. This lets lecturers answer what-if questions, and students can rerun the same tool at home.

## Advanced projects built on the toolkit

The toolkit removes much of the infrastructure work by supplying data structures, tools and interfaces. Several students expressed interest in putting their projects into the toolkit.

The probabilistic parsing project is the clearest case of extension. Its student added a probabilistic parsing interface and created probabilistic subclasses of the context free grammar structure. It reused the chart data structure and built two implementations of the new interface. A tutorial then explained the concepts and the new parts.

## What students said about the course use

NLTK served as the base for assignments and student projects in CIS-530, a graduate-level introductory class at the University of Pennsylvania. Students completed five assignments, two exams and a final project. The authors describe the experience as very positive for themselves and for the students.

Students liked starting interesting projects from the outset and running everything on their home computers. They found the documentation very helpful and called the interfaces intuitive. The authors report no quantitative measure of these reactions, so the evidence is observational.

## Limits of the course evidence

Finding large clean corpora was the main difficulty, and several students needed help finding corpora for their final projects.

The toolkit was still being developed during the term, and some modules were finished only one or two weeks before students used them. Students working at home had to download new versions several times, and Python's installation support made the updates simple. Students hit a couple of bugs, none of them serious, and they were quickly fixed.

The evidence comes from one course at one university. The authors are still working on modules for Hidden Markov Models, language modeling and tree adjoining grammars.

## How NLTK differs from earlier toolkits

Some books introduce programming to linguists, but they are elementary on the computing side. Grammar frameworks and finite-state toolkits have long found pedagogical use, though they were built for other purposes. Research toolkits such as the CMU-Cambridge Statistical Language Modeling Toolkit were not built for teaching, yet many have been used in classes.

The authors say NLTK was designed as courseware, with pedagogical goals as its primary status. Built on an object-oriented scripting language, it supports rapid prototyping and literate programming.

## Paper info

- **Authors**: Edward Loper, Steven Bird
- **Venue**: arXiv · Preprint
- **First published**: 2002-5-17
- **Added**: 2026-11-12
- **Updated**: 2002-5-17
- **Version**: v1
- **arXiv**: cs/0205028
- **Category**: cs.CL
- **Original paper terms**: [Check in the original ↗](https://arxiv.org/abs/cs/0205028v1)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/cs/0205028v1) · [PDF ↗](https://arxiv.org/pdf/cs/0205028v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Edward Loper, Steven Bird (2002). NLTK: The Natural Language Toolkit. arXiv:cs/0205028v1. https://arxiv.org/abs/cs/0205028v1

**BibTeX**

```
@misc{loper2002nltk,
  title = {{NLTK: The Natural Language Toolkit}},
  author = {Edward Loper and Steven Bird},
  year = {2002},
  eprint = {cs/0205028},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/cs/0205028v1}
}
```

## Other paper commentary

- [EDA: Easy Data Augmentation Techniques for Boosting Performance on Text Classification Tasks](https://refivu.com/en/papers/6bc7db3b-907c-40de-8993-2cc4b32ed04f-eda-easy-data-augmentation-techniques-for-boosting.md)
- [Thumbs up? Sentiment Classification using Machine Learning Techniques](https://refivu.com/en/papers/099cc783-1d4a-4899-b08c-ce3886810f1a-thumbs-up-sentiment-classification-using-machine-learning.md)
- [From Local to Global: A Graph RAG Approach to Query-Focused Summarization](https://refivu.com/en/papers/b90240e0-a6fe-4297-adb6-4ebd769e9c60-from-local-to-global-a-graph-rag-approach.md)
- [Abstractive Text Summarization Using Sequence-to-Sequence RNNs and Beyond](https://refivu.com/en/papers/7a55aaf9-654e-4a97-8efc-d0b4a9fccb7a-abstractive-text-summarization-using-sequence-to-sequence.md)
- [Teaching Machines to Read and Comprehend](https://refivu.com/en/papers/c971169f-9440-4e65-a62d-d8affa24f16a-teaching-machines-to-read-and-comprehend.md)
- [End-to-end Sequence Labeling via Bi-directional LSTM-CNNs-CRF](https://refivu.com/en/papers/ce633cbf-8295-40aa-a4ee-656b431af25f-end-to-end-sequence-labeling-via-bi-directional.md)
- [One pixel attack for fooling deep neural networks](https://refivu.com/en/papers/d5d76088-1786-441c-91fa-bf247a220946-one-pixel-attack-for-fooling-deep-neural-networks.md)
- [Self-training with Noisy Student improves ImageNet classification](https://refivu.com/en/papers/57e759e6-5034-4019-9e65-3fac466f7c21-self-training-with-noisy-student-improves-imagenet.md)
- [PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization](https://refivu.com/en/papers/d88e659c-e7cf-4fb4-acf4-46e297868666-posenet-a-convolutional-network-for-real-time-6.md)
- [Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks](https://refivu.com/en/papers/15731593-7d6d-4afb-b434-961a20dea639-gate-variants-of-gated-recurrent-unit-gru-neural.md)
- [Federated Learning with Differential Privacy: Algorithms and Performance Analysis](https://refivu.com/en/papers/159abc6e-c571-4ed4-b7d1-e630e54b4510-federated-learning-with-differential-privacy-algorithms-and.md)
- [Deep Learning for 3D Point Clouds: A Survey](https://refivu.com/en/papers/ac14ada0-64c3-463e-b921-6ac08239ba22-deep-learning-for-3d-point-clouds-a-survey.md)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/26e265b2-45d0-4d0e-b6a7-a161ecf1fe09-nltk-the-natural-language-toolkit)
