|
|
|
|
|
by pwf
4463 days ago
|
|
Is there a bug in the train function? Using 'lambda: 1' for the default dict along with '+=' means that the first time a feature is encountered, the value is set to 2. In [1]: from collections import defaultdict
In [2]: d = defaultdict(lambda: 1)
In [3]: d['foo'] += 1
In [4]: d['foo']
Out[4]: 2
|
|
That is to say, a word that appears once should get a count of 2, and word that doesn't appear at all should get a count of 1.