2.1
 NLTK

2.1.1
 Intro

NLTK (Natural Language Toolkit) 

NLTKhttp://www.nltk.org

Installationsanleitungen für Win, Mac, Linux

http://www.nltk.org/download

Bird et. al (2009): Natural Language Processing in Python 

pict

Modulübersicht 

Language processing task NLTK modules

Functionality

Accessing corpora nltk.corpus

standardized interfaces to corpora and lexicons

String processing nltk.tokenize, nltk.stem

tokenizers, sentence tokenizers, stemmers

Collocation discovery nltk.collocations

t-test, chi-squared, point-wise mutual information

Part-of-speech tagging nltk.tag

n-gram, backoff, Brill, HMM, TnT

Classification nltk.classify, nltk.cluster

decision tree, maximum entropy, naive Bayes, EM, k-means

Chunking nltk.chunk

regular expression, n-gram, named-entity

Parsing nltk.parse

chart, feature-based, unification, probabilistic, dependency

Semantic interpretation nltk.sem, nltk.inference

lambda calculus, first-order logic, model checking

Evaluation metrics nltk.metrics

precision, recall, agreement coefficients

Probability and estimation nltk.probability

frequency distributions, smoothed probability distributions

Applications nltk.app, nltk.chat

graphical concordancer, parsers, WordNet browser, chatbots

Linguistic fieldwork nltk.toolbox

manipulate data in SIL Toolbox format

2.1.2
 Module und Packages

Verzeichnisstruktur von NLTK 

$ tree /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/nltk/  
|-- __init__.py  
|-- __init__.pyc  
|-- align.py  
|-- align.pyc  
|-- app  
|   |-- __init__.py  
|   |-- __init__.pyc  
|   |-- chartparser_app.py  
|   |-- chartparser_app.pyc  
|   |-- chunkparser_app.py  
|   |-- chunkparser_app.pyc  
...

Module importieren 
Anweisung: import Module  12

 
# Importiere Modul book aus Package nltk 
import nltk.book 
 
# Objekte und Funktionen aus nltk.book können nur in 
# vollqualifizierter Punktnotation bezeichnet werden. 
print "Zweites Wort aus text1:", nltk.book.text1[1] 
 
# Objekte und Funktionen können nicht direkt bezeichnet werden: 
print text1[1]

Alle Objekte und Funktionen aus Modulen importieren 
Anweisung: from Module import *  13

 
# Lade Modul book aus Package nltk und 
# importiere alle Objekte und Funktionen ins aktuelle Modul 
from nltk.book import * 
 
# Objekte und Funktionen aus nltk.book können ohne 
# Modulpräfixe bezeichnet werden. 
print "Zweites Token aus text1:", text1[1] 
 
# Die vollqualifizierter Punktnotation geht dann nicht 
print "Zweites Wort aus text1:", nltk.book.text1[1]

2.1.3
 Demo-Tour

Eine Tour durch Kapitel 1