Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some minimal tests; found and fixed a bias bug in analysis.Analyzer.
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import analysis | ||
import unittest | ||
|
||
class SubjectTests(unittest.TestCase) : | ||
def setUp(self) : | ||
self.analyzer = analysis.Analyzer() | ||
|
||
def test_nosubject(self) : | ||
self.assertEqual(None, self.analyzer.categorize("I the and then. The. Yes.")) | ||
|
||
def test_specific_subject(self) : | ||
self.assertEqual("COMPUTERS", self.analyzer.categorize("Use python. Problem solved.")) | ||
|
||
def test_random_subject(self) : | ||
n_outdoors = 0 | ||
n_computers = 0 | ||
for i in xrange(10000) : | ||
cat = self.analyzer.categorize("Use python. Ski later.") | ||
if cat == "COMPUTERS" : | ||
n_computers += 1 | ||
elif cat == "OUTDOORS" : | ||
n_outdoors += 1 | ||
else : | ||
self.fail("did not expect category %s" % cat) | ||
|
||
if n_outdoors > 0 and n_computers > 0 : | ||
break | ||
|
||
self.assertTrue(n_outdoors > 0) | ||
self.assertTrue(n_computers > 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters