Skip to content

Commit

Permalink
Update DictUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
dchentech committed Sep 15, 2014
1 parent 17bde28 commit f5e1e7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
zip_safe=False,
platforms='any',
install_requires=[
'etl_utils',
'etl_utils >= 0.0.9',
],
classifiers=[
'Intended Audience :: Developers',
Expand Down
6 changes: 3 additions & 3 deletions tfidf/tfidf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

import math
from etl_utils import process_notifier, cpickle_cache, cached_property
from etl_utils import process_notifier, cpickle_cache, cached_property, DictUtils
from collections import defaultdict, Counter

class TfIdf():
Expand All @@ -14,9 +14,9 @@ def __init__(self, documents_or_func, cache_dir):
self.documents_or_func = documents_or_func
self.cache_dir = cache_dir

self.idf_default_val = sum(self.idf_cache.values()) / float(len(self.idf_cache))
# Always load idf cache, and it's really small.
self.idf_cache = IdfResult(lambda : self.idf_default_val, self.idf_cache)
d1 = DictUtils.add_default_value(self.idf_cache)
self.idf_cache = IdfResult(d1.default_factory, d1)

@cached_property
def documents(self):
Expand Down

0 comments on commit f5e1e7d

Please sign in to comment.