This commit is contained in:
Crista Lopes
2013-12-26 12:14:00 -08:00
parent a8760fbcb3
commit 116caa26b6

View File

@@ -36,9 +36,8 @@ class DataStorageManager(ActiveWFObject):
def _init(self, message): def _init(self, message):
path_to_file = message[0] path_to_file = message[0]
self._stop_word_manager = message[1] self._stop_word_manager = message[1]
f = open(path_to_file) with open(path_to_file) as f:
self._data = f.read() self._data = f.read()
f.close()
pattern = re.compile('[\W_]+') pattern = re.compile('[\W_]+')
self._data = pattern.sub(' ', self._data).lower() self._data = pattern.sub(' ', self._data).lower()
@@ -65,9 +64,8 @@ class StopWordManager(ActiveWFObject):
self._word_freqs_manager.queue.put(message) self._word_freqs_manager.queue.put(message)
def _init(self, message): def _init(self, message):
f = open('../stop_words.txt') with open('../stop_words.txt') as f:
self._stop_words = f.read().split(',') self._stop_words = f.read().split(',')
f.close()
self._stop_words.extend(list(string.ascii_lowercase)) self._stop_words.extend(list(string.ascii_lowercase))
self._word_freqs_manager = message[0] self._word_freqs_manager = message[0]