MCPcopy Create free account
hub / github.com/clips/pattern / test_bag_of_words

Method test_bag_of_words

test/test_text.py:125–133  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

123 self.assertEqual(s(v).assessments[1], ([":-)"], +1.0, 1.0))
124
125 def test_bag_of_words(self):
126 # Assert weighted average polarity and subjectivity for bag-of-words with weighted features.
127 from pattern.vector import BagOfWords # Alias for pattern.vector.Document.
128 s = text.Sentiment()
129 v = BagOfWords({":-(": 3, ":-)": 1})
130 self.assertEqual(s(v)[0], -0.5)
131 self.assertEqual(s(v)[1], +1.0)
132 self.assertEqual(s(v).assessments[0], ([":-("], -1.0, 1.0))
133 self.assertEqual(s(v).assessments[1], ([":-)"], +1.0, 1.0))
134
135#---------------------------------------------------------------------------------------------------
136

Callers

nothing calls this directly

Calls 1

sFunction · 0.85

Tested by

no test coverage detected