예제 #1
0
 def test_completeness_first(self):
     #Here, the word "the" has three entries in the original MRC db.
     #This test checks if MY mrc db has the more complete entry when the
     #most complete entry is the first one of the three.
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     words = buildMRC("test/testMRC.dct")
     exp = Word(3, 2, 1, 69971, 15, 500, 236472, 6833, 625, 237, 209, 212,
                0, 0, 12)
     got = words["THE"]
     self.assertEqual(exp.nlet, got.nlet)
     self.assertEqual(exp.nphon, got.nphon)
     self.assertEqual(exp.nsyl, got.nsyl)
     self.assertEqual(exp.kffreq, got.kffreq)
     self.assertEqual(exp.kfcats, got.kfcats)
     self.assertEqual(exp.kfsamps, got.kfsamps)
     self.assertEqual(exp.tlfreq, got.tlfreq)
     self.assertEqual(exp.bfreq, got.bfreq)
     self.assertEqual(exp.fam, got.fam)
     self.assertEqual(exp.conc, got.conc)
     self.assertEqual(exp.imag, got.imag)
     self.assertEqual(exp.meanc, got.meanc)
     self.assertEqual(exp.meanp, got.meanp)
     self.assertEqual(exp.aoa, got.aoa)
     self.assertEqual(exp.numScores, got.numScores)
예제 #2
0
 def test_scoring_nonsense(self):
     #Score a review where none of the words are going to be found in the db.
     #Should return a zero for every score except original word count.
     os.chdir("/Users/landon/Dropbox/Amazon project/")
     words = buildMRC("1054/mrc2.dct")
     exp = [0] * 43
     exp[0] = 3
     got = scoreReview(words, "dis nu NUUU 123")
     self.assertEqual(exp, got)
예제 #3
0
 def test_review4(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/")
     words = buildMRC("1054/mrc2.dct")
     exp = [
         28, 27, 140, 5.185, 24, 95, 3.958, 26, 41, 1.577, 26, 7193,
         276.654, 26, 352, 13.538, 26, 3458, 133.0, 24, 55724, 2321.833, 26,
         3021, 116.192, 18, 10562, 586.778, 17, 6644, 390.824, 18, 7972,
         442.889, 17, 7590, 446.471, 3, 2026, 675.333, 6, 1659, 276.5
     ]
     got = scoreReview(
         words,
         "ABSOLUTELY LOVE IT!!! Battery life is great, connects to my phone very easily (note 4). Setup took less than five minutes. The only reason I'm putting 4 stars is because when I opened the box everything inside looked like it was just thrown in. Other than that I'm very happy with my purchase."
     )
     self.assertEqual(exp, got)
예제 #4
0
 def test_review3(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/")
     words = buildMRC("1054/mrc2.dct")
     exp = [
         12, 12, 66, 5.5, 8, 33, 4.125, 9, 12, 1.333, 9, 3162, 351.333, 9,
         121, 13.444, 9, 1587, 176.333, 9, 20739, 2304.333, 11, 724, 65.818,
         8, 4531, 566.375, 8, 3336, 417.0, 8, 3504, 438.0, 6, 2634, 439.0,
         0, 0, 0, 4, 1441, 360.25
     ]
     got = scoreReview(
         words,
         "a great case. hard to take off!... BUT the protection makes up for it. Thanks! :)\nI'll definitely purchase a case from these guys again."
     )
     self.assertEqual(exp, got)
예제 #5
0
 def test_review2(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/")
     words = buildMRC("1054/mrc2.dct")
     exp = [
         15, 15, 74, 4.933, 14, 51, 3.643, 14, 19, 1.357, 14, 3738, 267, 14,
         185, 13.214, 14, 1953, 139.5, 14, 24654, 1761.0, 15, 1930, 128.667,
         9, 5122, 569.111, 7, 3087, 441.0, 9, 3625, 402.778, 7, 3178, 454,
         0, 0, 0, 0, 0, 0
     ]
     got = scoreReview(
         words,
         "This is a solid PHONE! DEFINITELY. I really enjoyed using it. Not a huge fan of the screen... but I can make it work. The best phone ever, really!"
     )
     self.assertEqual(exp, got)
예제 #6
0
 def test_review(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/")
     words = buildMRC("1054/mrc2.dct")
     #Here, our expected is derived by manually searching the DB for each (reduced) review
     #and scoring it. The results of this manual labor can be found in scoreReviewTest.xlsxs
     exp = [
         16, 16, 73, 4.562, 13, 47, 3.615, 14, 17, 1.214, 14, 3215, 229.643,
         14, 162, 11.571, 14, 1560, 111.429, 13, 28502, 2192.462, 14, 956,
         68.286, 11, 6143, 558.455, 11, 4691, 426.455, 11, 4952, 450.182,
         10, 4555, 455.5, 1, 688, 688.0, 3, 883, 294.333
     ]
     got = scoreReview(
         words,
         "The hose attachment has to be placed on when you want to use it and my bare floor tool was missing. Looks nice and the floor options seems to work ok."
     )
     self.assertEqual(exp, got)
예제 #7
0
 def test_abdomen(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     words = buildMRC("test/testMRC.dct")
     exp = Word(7, 7, 3, 6, 5, 6, 49, 0, 426, 586, 548, 0, 475, 556, 12)
     got = words["ABDOMEN"]
     self.assertEqual(exp.nlet, got.nlet)
     self.assertEqual(exp.nphon, got.nphon)
     self.assertEqual(exp.nsyl, got.nsyl)
     self.assertEqual(exp.kffreq, got.kffreq)
     self.assertEqual(exp.kfcats, got.kfcats)
     self.assertEqual(exp.kfsamps, got.kfsamps)
     self.assertEqual(exp.tlfreq, got.tlfreq)
     self.assertEqual(exp.bfreq, got.bfreq)
     self.assertEqual(exp.fam, got.fam)
     self.assertEqual(exp.conc, got.conc)
     self.assertEqual(exp.imag, got.imag)
     self.assertEqual(exp.meanc, got.meanc)
     self.assertEqual(exp.meanp, got.meanp)
     self.assertEqual(exp.aoa, got.aoa)
     self.assertEqual(exp.numScores, got.numScores)
예제 #8
0
 def test_seek(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     words = buildMRC("test/testMRC.dct")
     exp = Word(4, 3, 1, 69, 13, 57, 288, 0, 506, 375, 335, 412, 0, 0, 11)
     got = words["SEEK"]
     self.assertEqual(exp.nlet, got.nlet)
     self.assertEqual(exp.nphon, got.nphon)
     self.assertEqual(exp.nsyl, got.nsyl)
     self.assertEqual(exp.kffreq, got.kffreq)
     self.assertEqual(exp.kfcats, got.kfcats)
     self.assertEqual(exp.kfsamps, got.kfsamps)
     self.assertEqual(exp.tlfreq, got.tlfreq)
     self.assertEqual(exp.bfreq, got.bfreq)
     self.assertEqual(exp.fam, got.fam)
     self.assertEqual(exp.conc, got.conc)
     self.assertEqual(exp.imag, got.imag)
     self.assertEqual(exp.meanc, got.meanc)
     self.assertEqual(exp.meanp, got.meanp)
     self.assertEqual(exp.aoa, got.aoa)
     self.assertEqual(exp.numScores, got.numScores)
예제 #9
0
 def test_seem(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     words = buildMRC("test/testMRC.dct")
     exp = Word(4, 3, 1, 229, 15, 154, 4577, 48, 549, 226, 249, 325, 0, 0,
                12)
     got = words["SEEM"]
     self.assertEqual(exp.nlet, got.nlet)
     self.assertEqual(exp.nphon, got.nphon)
     self.assertEqual(exp.nsyl, got.nsyl)
     self.assertEqual(exp.kffreq, got.kffreq)
     self.assertEqual(exp.kfcats, got.kfcats)
     self.assertEqual(exp.kfsamps, got.kfsamps)
     self.assertEqual(exp.tlfreq, got.tlfreq)
     self.assertEqual(exp.bfreq, got.bfreq)
     self.assertEqual(exp.fam, got.fam)
     self.assertEqual(exp.conc, got.conc)
     self.assertEqual(exp.imag, got.imag)
     self.assertEqual(exp.meanc, got.meanc)
     self.assertEqual(exp.meanp, got.meanp)
     self.assertEqual(exp.aoa, got.aoa)
     self.assertEqual(exp.numScores, got.numScores)
예제 #10
0
 def test_incomplete_entries(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     #Make sure that, even though it is essentially an incomplete entry, that
     #"placed" is in our db. The only reason for this is because the original
     #MRC db does not contain a "better" entry; no entry for "placed" is complete
     words = buildMRC("test/testMRC.dct")
     exp = Word(6, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2)
     got = words["PLACED"]
     self.assertEqual(exp.nlet, got.nlet)
     self.assertEqual(exp.nphon, got.nphon)
     self.assertEqual(exp.nsyl, got.nsyl)
     self.assertEqual(exp.kffreq, got.kffreq)
     self.assertEqual(exp.kfcats, got.kfcats)
     self.assertEqual(exp.kfsamps, got.kfsamps)
     self.assertEqual(exp.tlfreq, got.tlfreq)
     self.assertEqual(exp.bfreq, got.bfreq)
     self.assertEqual(exp.fam, got.fam)
     self.assertEqual(exp.conc, got.conc)
     self.assertEqual(exp.imag, got.imag)
     self.assertEqual(exp.meanc, got.meanc)
     self.assertEqual(exp.meanp, got.meanp)
     self.assertEqual(exp.aoa, got.aoa)
     self.assertEqual(exp.numScores, got.numScores)
예제 #11
0
 def test_word_not_found(self):
     os.chdir("/Users/landon/Dropbox/Amazon project/"
              )  #change this to the project directory
     words = buildMRC("test/testMRC.dct")
     with self.assertRaises(KeyError):
         words["FAKE"]