The following code is supposed to create a new (modified) version of a frequency distribution (nltk.FreqDist). Both variables should then be the same length.
It works f
class WebText:
freq_dist_weighted = {}
declares freq_dist_weighted
so that it is shared between all objects of type WebText
; essentially, this is like a static
member in C++.
If you want each WebText
object to have its own freq_dist_weighted
member (i.e. you can change it for one instance without changing it for another instance), you want to define it in __init__
:
class WebText:
def __init__(self):
self.freq_dist_weighted = {}