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

Method term_frequency

pattern/vector/__init__.py:518–523  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

test_tfMethod · 0.95

Calls 1

getMethod · 0.45

Tested by 1

test_tfMethod · 0.76