Processing text corpora with NLTK

Aus Westslawische Sprachen

Version vom 13. Mai 2017, 23:12 Uhr von Meyerrol (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Here is an elegant way to process your text data with professional CL tools: Import it into [http://nltk.org NLTK], the _Natural Language Toolkit_ for Python3…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Here is an elegant way to process your text data with professional CL tools: Import it into NLTK, the _Natural Language Toolkit_ for Python3 and use all the processing tools available in NLTK.

Let us assume you have Python3 and the NLTK installed (if you haven't, follow the instructions in How to install Python3 and the NLTK. Furthermore, let us assume that your corpus texts are in UTF-8 format and stored in the folder `/Users/roland/mycorpus`. Then open a Python3 shell (IDLE, command line or other) and type

> import nltk > from nltk.corpus import PlaintextCorpusReader > root = "/Users/roland/mycorpus" > mycorpus = PlaintextCorpusReader(root, '.*') # mycorpus is a nltk.Corpus > mycorpusText = nltk.Text(mycorpus.words()) # mycorpusText is a nltk.Text > mycorpus.words() > mycorpusText.concordance("кое-какое")