November 2020
Beginner to intermediate
360 pages
9h 32m
English

This appendix contains solutions to the practice projects in each chapter. Digital versions are available on the book’s website at https://nostarch.com/real-world-python/.
practice_hound_dispersion.py
"""Use NLP (nltk) to make dispersion plot."""
import nltk
def text_to_string(filename):
strings = []
with open(filename) as f:
strings.append(f.read())
return '\n'.join(strings)
corpus = text_to_string('hound.txt')
tokens = nltk.word_tokenize(corpus)
tokens = nltk.Text(tokens) # NLTK wrapper for automatic text analysis.
dispersion ...Read now
Unlock full access