예제 #1
0
    def test_term_frequency_for(self):
        document_tokens = ["cisco", "router", "cisco", "switch"]

        frequencies = WeighingMeasure.term_frequency_for(document_tokens)

        self.assertEqual(len(frequencies.keys()), 3)
        self.assertEqual(frequencies["cisco"], 2)
        self.assertEqual(frequencies["router"], 1)
예제 #2
0
파일: document.py 프로젝트: katta/watson
 def term_frequencies(self):
     if len(self.term_frequency) == 0:
         self.term_frequency = WeighingMeasure.term_frequency_for(self.all_tokens())
     return self.term_frequency