- Python Machine Learning By Example
- Yuxi (Hayden) Liu
- 310字
- 2021-07-02 12:41:39
Corpus
As of 2018, NLTK comes with over 100 collections of large and well-structured text datasets, which are called corpora in NLP. Corpora can be used as dictionaries for checking word occurrences and as training pools for model learning and validating. Some useful and interesting corpora include Web Text corpus, Twitter samples, Shakespeare corpus sample, Sentiment Polarity, Names corpus (it contains lists of popular names, which we will be exploring very shortly), WordNet, and the Reuters benchmark corpus. The full list can be found at http://www.nltk.org/nltk_data. Before using any of these corpus resources, we need to first download them by running the following codes in the Python interpreter:
>>> import nltk
>>> nltk.download()
A new window will pop up and ask us which collections (the Collections tab in the following screenshot) or corpus (the Corpora tab in the following screenshot) to download, and where to keep the data:

Installing the whole popular package is the quick solution, since it contains all important corpora needed for your current study and future research. Installing a particular corpora, as shown in the following screenshot, is also fine:

Once the package or corpus you want to explore is installed, we can now take a look at the Names corpus (make sure the names corpus is installed).
First, import the corpus names:
>>> from nltk.corpus import names
We can check out the first 10 names in the list:
>>> print(names.words()[:10])
['Abagael', 'Abagail', 'Abbe', 'Abbey', 'Abbi', 'Abbie',
'Abby', 'Abigael', 'Abigail', 'Abigale']
There are, in total, 7944 names, as shown in the following output derived by executing the following command:
>>> print(len(names.words()))
7944
Other corpora are also fun to explore.
Besides the easy-to-use and abundant corpora pool, more importantly, NLTK is also good at many NLP and text analysis tasks including tokenization, PoS tagging, named entities recognition, word stemming, and lemmatization.
- 平面設計初步
- Getting Started with Containerization
- 自動檢測與轉換技術
- 機器學習流水線實戰
- 基于ARM 32位高速嵌入式微控制器
- 大學C/C++語言程序設計基礎
- 寒江獨釣:Windows內核安全編程
- Web編程基礎
- 3ds Max造型表現藝術
- 貫通Java Web輕量級應用開發
- 從機器學習到無人駕駛
- Appcelerator Titanium Smartphone App Development Cookbook(Second Edition)
- 大數據:從基礎理論到最佳實踐
- Flash 8中文版全程自學手冊
- Cloud Native Development Patterns and Best Practices