|
@@ -94,7 +94,14 @@ class testTextAnalysis(unittest.TestCase):
|
|
|
expectedCounts = {'his': 7, 'every': 5, 'like': 4, 'thou': 3, 'however,': 3, 'was': 6, 'he': 6, 'and': 13, 'which': 3, 'a': 6, 'the': 21}
|
|
|
counts = idiolectalyzer.findRepeatWords(testText,3)
|
|
|
self.assertEqual(expectedCounts, counts)
|
|
|
-
|
|
|
+ expectedCounts = [('the', 21), ('and', 13), ('his', 7), ('was', 6), ('he', 6)]
|
|
|
+ counts = idiolectalyzer.findRepeatWords(testText,3,maxWords=5)
|
|
|
+ self.assertEqual(expectedCounts, counts)
|
|
|
+ counts = idiolectalyzer.findRepeatWords(testText,3,maxWords='invalid')
|
|
|
+ self.assertEqual(False,counts)
|
|
|
+ counts = idiolectalyzer.findRepeatWords(testText,3,context='invalid')
|
|
|
+ self.assertEqual(False,counts)
|
|
|
+
|
|
|
def testHowCommonIs(self):
|
|
|
google1965Expectation = 8131
|
|
|
allgoogleExpectation = 6321
|
|
@@ -111,15 +118,8 @@ class testTextAnalysis(unittest.TestCase):
|
|
|
testTextFile="mockdata/withspellingerrors.txt"
|
|
|
testText = readTestText(testTextFile)
|
|
|
spellingErrorsCount=idiolectalyzer.findCommonMisspellings(testText,'count')
|
|
|
- countedHeigth = spellingErrorsCount['heigth']
|
|
|
- expectedHeigth = 7
|
|
|
- countedBecuase = spellingErrorsCount['becuase']
|
|
|
- expectedBecuase = 4
|
|
|
- countedEcstacy = spellingErrorsCount['ecstacy']
|
|
|
- expectedEcstacy = 1
|
|
|
- self.assertEqual(countedHeigth,expectedHeigth)
|
|
|
- self.assertEqual(countedBecuase,expectedBecuase)
|
|
|
- self.assertEqual(countedEcstacy,expectedEcstacy)
|
|
|
+ expectedCounts = {'ecstacy': 1, 'becuase': 4, 'heigth': 7}
|
|
|
+ self.assertEqual(expectedCounts, spellingErrorsCount)
|
|
|
|
|
|
testTextFile="mockdata/251words.txt"
|
|
|
testText = readTestText(testTextFile)
|
|
@@ -127,5 +127,11 @@ class testTextAnalysis(unittest.TestCase):
|
|
|
expectedResult = None
|
|
|
self.assertEqual(spellingErrorsCount,expectedResult)
|
|
|
|
|
|
+ def testFrequencyOfRepeats(self):
|
|
|
+ counts = [('the', 21), ('and', 13), ('his', 7), ('was', 6), ('he', 6), ('alsidkfjads', 7)]
|
|
|
+ expectedFrequency = [3, 67, 'unique', 1, 30, 53]
|
|
|
+ frequency = idiolectalyzer.frequencyOfRepeats(counts)
|
|
|
+ self.assertEqual(expectedFrequency,frequency)
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
unittest.main()
|