def testTotalCount(self): """ Testing to see if the reduce function returns an accurate count of the total number of words in all articles. """ articleList = [] for string in self.strings: articleList.append(wordcount.wordcount(string)) theList = [] for string in self.theTwentyFive: theList.append(wordcount.wordcount(string)) emptyCount = wordcount.wordcount(self.emptyString) wcBulkDict = wordcount.reduce(articleList) wcTheDict = wordcount.reduce(theList) self.assertEqual(sum(emptyCount.values()), 0) self.assertEqual(sum(wcBulkDict.values()), 65) self.assertEqual(sum(wcTheDict.values()), 25)
def testBulkCount(self): """ Testing to see if the reduce function can count the occurrence of a word over a list of articles. """ articleList = [] for string in self.strings: articleList.append(wordcount.wordcount(string)) wcBulkDict = wordcount.reduce(articleList) self.assertEqual(wcBulkDict["bureaucracy"], 1) self.assertEqual(wcBulkDict["bureaucracy."], 1) self.assertEqual(wcBulkDict["bureaucracy;"], 0) self.assertEqual(wcBulkDict["The"], 1) self.assertEqual(wcBulkDict["the"], 8) self.assertEqual(wcBulkDict["You"], 1) self.assertEqual(wcBulkDict["you"], 3) self.assertEqual(wcBulkDict["to"], 4) self.assertEqual(wcBulkDict["be"], 3)