| 222 | print "pattern.vector.stem()" |
| 223 | |
| 224 | def test_count(self): |
| 225 | # Assert wordcount with stemming, stopwords and pruning. |
| 226 | w = ["The", "cats", "sat", "on", "the", "mat", "."] |
| 227 | v1 = vector.count(w) |
| 228 | v2 = vector.count(w, stemmer=vector.LEMMA) |
| 229 | v3 = vector.count(w, exclude=["."]) |
| 230 | v4 = vector.count(w, stopwords=True) |
| 231 | v5 = vector.count(w, stopwords=True, top=3) |
| 232 | v6 = vector.count(w, stopwords=True, top=3, threshold=1) |
| 233 | v7 = vector.count(w, dict=vector.readonlydict, cached=False) |
| 234 | self.assertEqual(v1, {"cats":1, "sat":1, "mat":1, ".":1}) |
| 235 | self.assertEqual(v2, {"cat":1, "sat":1, "mat":1, ".":1}) |
| 236 | self.assertEqual(v3, {"cats":1, "sat":1, "mat":1}) |
| 237 | self.assertEqual(v4, {"the":2, "cats":1, "sat":1, "on":1, "mat":1, ".":1}) |
| 238 | self.assertEqual(v5, {"the":2, "cats":1, ".":1}) |
| 239 | self.assertEqual(v6, {"the":2}) |
| 240 | # Assert custom dict class. |
| 241 | self.assertTrue(isinstance(v7, vector.readonlydict)) |
| 242 | print "pattern.vector.count()" |
| 243 | |
| 244 | def test_document(self): |
| 245 | # Assert Document properties. |