Changed names to match exactly those of style 10

This commit is contained in:
Crista Lopes
2013-12-06 10:41:19 -08:00
parent dd0700368e
commit 865dbc3540

View File

@@ -39,7 +39,7 @@ class IWordFrequencyCounter(object):
# #
# The concrete things # The concrete things
# #
class DataStorage: class DataStorageManager:
_data = '' _data = ''
def __init__(self, path_to_file): def __init__(self, path_to_file):
with open(path_to_file) as f: with open(path_to_file) as f:
@@ -51,7 +51,7 @@ class DataStorage:
def words(self): def words(self):
return self._data return self._data
class StopWordFilter: class StopWordManager:
_stop_words = [] _stop_words = []
def __init__(self): def __init__(self):
with open('../stop_words.txt') as f: with open('../stop_words.txt') as f:
@@ -61,7 +61,7 @@ class StopWordFilter:
def is_stop_word(self, word): def is_stop_word(self, word):
return word in self._stop_words return word in self._stop_words
class WordFrequencyCounter: class WordFrequencyManager:
_word_freqs = {} _word_freqs = {}
def increment_count(self, word): def increment_count(self, word):
@@ -77,18 +77,18 @@ class WordFrequencyCounter:
# #
# The wiring between abstract things and concrete things # The wiring between abstract things and concrete things
# #
IDataStorage.register(DataStorage) IDataStorage.register(DataStorageManager)
IStopWordFilter.register(StopWordFilter) IStopWordFilter.register(StopWordManager)
IWordFrequencyCounter.register(WordFrequencyCounter) IWordFrequencyCounter.register(WordFrequencyManager)
# #
# The application object # The application object
# #
class WordFrequencyApplication: class WordFrequencyController:
def __init__(self, path_to_file): def __init__(self, path_to_file):
self._storage = DataStorage(path_to_file) self._storage = DataStorageManager(path_to_file)
self._stop_word_manager = StopWordFilter() self._stop_word_manager = StopWordManager()
self._word_freq_counter = WordFrequencyCounter() self._word_freq_counter = WordFrequencyManager()
def run(self): def run(self):
for w in self._storage.words(): for w in self._storage.words():
@@ -102,4 +102,4 @@ class WordFrequencyApplication:
# #
# The main function # The main function
# #
WordFrequencyApplication(sys.argv[1]).run() WordFrequencyController(sys.argv[1]).run()