class_docstr: The original Okapi BM25 scoring function of Robertson et al. [2]_.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import Dictionary
      >>> from gensim.models import OkapiBM25Model
      >>> from gensim.test.utils import common_texts
      >>>
      >>> dictionary = Dictionary(common_texts)  # fit dictionary
      >>> model = OkapiBM25Model(dictionary=dictionary)  # fit model
      >>>
      >>> corpus = [dictionary.doc2bow(line) for line in common_texts]  # convert corpus to BoW format
      >>> vector = model[corpus[0]]  # apply model to the first corpus document
  
  References
  ----------
  .. [2] Robertson S. E., Walker S., Jones S., Hancock-Beaulieu M. M., Gatford M. (1995).
     `Okapi at TREC-3 <http://research.microsoft.com/pubs/67649/okapi_trec3.pdf>`_.
     *NIST Special Publication 500-226*.
class_docstr_tok: ["The","original","Okapi","BM25","scoring","function","of","Robertson","et","al",".","[","2","]","_",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">","from","gensim.models","import","OkapiBM25Model",">",">",">","from","gensim.test.utils","import","common_texts",">",">",">",">",">",">","dictionary","=","Dictionary","(","common_texts",")","#","fit","dictionary",">",">",">","model","=","OkapiBM25Model","(","dictionary=dictionary",")","#","fit","model",">",">",">",">",">",">","corpus","=","[","dictionary.doc2bow","(","line",")","for","line","in","common_texts","]","#","convert","corpus","to","BoW","format",">",">",">","vector","=","model","[","corpus","[","0","]","]","#","apply","model","to","the","first","corpus","document","References","--","--","--","--","--","..","[","2","]","Robertson","S.","E.",",","Walker","S.",",","Jones","S.",",","Hancock-Beaulieu","M.","M.",",","Gatford","M.","(","1995",")",".","`","Okapi","at","TREC-3","<","http",":","\/\/research.microsoft.com\/pubs\/67649\/okapi_trec3.pdf",">","`","_",".","*","NIST","Special","Publication","500-226","*","."]
code: def precompute_idfs(self, dfs, num_docs):
      idf_sum = 0
      idfs = dict()
      negative_idfs = []
      for term_id, freq in dfs.items():
          idf = math.log(num_docs - freq + 0.5) - math.log(freq + 0.5)
          idfs[term_id] = idf
          idf_sum += idf
          if idf < 0:
              negative_idfs.append(term_id)
      average_idf = idf_sum / len(idfs)
  
      eps = self.epsilon * average_idf
      for term_id in negative_idfs:
          idfs[term_id] = eps
  
      return idfs
  
imports: from abc import ABCMeta, abstractmethod
  from collections import defaultdict
  import logging
  import math
  from gensim import interfaces, utils
  import numpy
label_desc: Use image node_id 2 for calling the OkapiBM25Model obj's underlying member method code with example usage: obj.precompute_idfs(dfs, num_docs) and returns: idfs