class TestPatternSentiment(unittest.TestCase): def setUp(self): self.analyzer = PatternAnalyzer() def test_kind(self): assert_equal(self.analyzer.kind, CONTINUOUS) def test_analyze(self): p1 = "I feel great this morning." n1 = "This is a terrible car." assert_true(self.analyzer.analyze(p1)[0] > 0) assert_true(self.analyzer.analyze(n1)[0] < 0)
def test_can_get_subjectivity_and_polarity_with_different_analyzer(self): blob = tb.TextBlob("I love this car.", analyzer=NaiveBayesAnalyzer()) pattern = PatternAnalyzer() assert_equal(blob.polarity, pattern.analyze(str(blob))[0]) assert_equal(blob.subjectivity, pattern.analyze(str(blob))[1])
def setUp(self): self.analyzer = PatternAnalyzer()