MCPcopy Index your code
hub / github.com/clips/pattern / test_document_keywords

Method test_document_keywords

test/test_vector.py:304–312  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

302 print "pattern.vector.Document.vector"
303
304 def test_document_keywords(self):
305 # Assert Document.keywords() based on term frequency.
306 v = vector.Document(["cat", "cat", "cat", "sat", "sat", "mat"]).keywords(top=2)
307 self.assertEqual(len(v), 2)
308 self.assertEqual(v[0][1], "cat")
309 self.assertEqual(v[1][1], "sat")
310 self.assertAlmostEqual(v[0][0], 0.50, places=2)
311 self.assertAlmostEqual(v[1][0], 0.33, places=2)
312 print "pattern.vector.Document.keywords()"
313
314 def test_tf(self):
315 # Assert Document.term_frequency() (= weights used in Vector for orphaned documents).

Callers

nothing calls this directly

Calls 2

lenFunction · 0.85
keywordsMethod · 0.80

Tested by

no test coverage detected