'The number of texts in the corpus divided by the
number of texts that the term appears in.
If a term does not appear in the corpus, 0.0 is returned.'

def idf(self, term):

    idf = self._idf_cache.get(term)
    if (idf is None):
        matches = len([True for text in self._texts if (term in text)])
        idf = (log((len(self._texts) / matches)) if matches else 0.0)
        self._idf_cache[term] = idf
    return idf
