Returns the term frequency of a given word in the document (0.0-1.0). tf = number of occurences of the word / number of words in document. The more occurences of the word, the higher its relative tf weight.
(self, word)
| 516 | return self.terms.get(word, default) |
| 517 | |
| 518 | def term_frequency(self, word): |
| 519 | """ Returns the term frequency of a given word in the document (0.0-1.0). |
| 520 | tf = number of occurences of the word / number of words in document. |
| 521 | The more occurences of the word, the higher its relative tf weight. |
| 522 | """ |
| 523 | return float(self.terms.get(word, 0)) / (self.count or 1) |
| 524 | |
| 525 | tf = term_frequency |
| 526 |