An ordered dictionary is like a normal dict
, but the keys are ordered by an ordering function. In the case of Redis, it supports ordered dictionaries whose keys are strings and whose values are floating point scores. This structure can come in handy in cases where we need to calculate the information gain (covered in the Calculating high information words recipe in Chapter 7, Text Classification), and when you want to store all the words and scores for later use.
Again, you'll need Redis
and redis-py
installed with an instance of redis-server
running, as explained in the earlier recipe, Storing a frequency distribution in Redis.
The RedisOrderedDict
class in rediscollections.py
No credit card required