Example #1
0
File: test.py Project: mvj3/tfidf
    def test_tfidf(self):
        clean_tmp()

        t = TfIdf(self.data, root_dir)
        self.assertTrue(t.idf_cache['I'] < t.idf_cache['hello'])
        self.assertTrue(t.idf_cache['I'] < t.idf_cache['You'])
        self.assertTrue(t.idf_cache['I'] < t.idf_cache['not exist feature'],
                        "test default idf_default_val")

        result1 = t.tfidf_in_a_doc(self.data[1])
        self.assertTrue(result1['I'] < result1['You'])
        self.assertTrue(result1['You'] < result1['hello'])
        self.assertTrue(result1['hello'] == result1['world'])

        clean_tmp()