Example #1
0
 def test_dict(self):
     # Assert weighted average polarity and subjectivity for dictionary.
     s = text.Sentiment()
     v = {":-(": 4, ":-)": 1}
     self.assertEqual(s(v)[0], -0.5)
     self.assertEqual(s(v)[1], +1.0)
     self.assertEqual(s(v).assessments[0], ([":-("], -0.75, 1.0, "mood"))
     self.assertEqual(s(v).assessments[1], ([":-)"], +0.50, 1.0, "mood"))
     print("pattern.text.Sentiment.assessments")
Example #2
0
 def test_bag_of_words(self):
     # Assert weighted average polarity and subjectivity for bag-of-words with weighted features.
     from pattern.vector import BagOfWords  # Alias for pattern.vector.Document.
     s = text.Sentiment()
     v = BagOfWords({":-(": 4, ":-)": 1})
     self.assertEqual(s(v)[0], -0.5)
     self.assertEqual(s(v)[1], +1.0)
     self.assertEqual(s(v).assessments[0], ([":-("], -0.75, 1.0, "mood"))
     self.assertEqual(s(v).assessments[1], ([":-)"], +0.50, 1.0, "mood"))