Storing a conditional frequency distribution in Redis
The nltk.probability.ConditionalFreqDist
class is a container for FreqDist
instances, with one FreqDist
per condition. It is used to count frequencies that are dependent on another condition, such as another word or a class label. We used this class in the Calculating high information words recipe in Chapter 7, Text Classification. Here, we'll create an API-compatible class on top of Redis using the RedisHashFreqDist
from the previous recipe.
Getting ready
As in the previous recipe, you'll need to have Redis
and redis-py
installed with an instance of redis-server
running.
How to do it...
We define a RedisConditionalHashFreqDist
class in redisprob.py
that extends nltk.probability.ConditionalFreqDist ...
Get Python 3 Text Processing with NLTK 3 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.