class_docstr: Objects of this class realize the transformation between word-document co-occurrence matrix (int)
  into a locally/globally weighted TF-IDF matrix (positive floats).
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> import gensim.downloader as api
      >>> from gensim.models import TfidfModel
      >>> from gensim.corpora import Dictionary
      >>>
      >>> dataset = api.load("text8")
      >>> dct = Dictionary(dataset)  # fit dictionary
      >>> corpus = [dct.doc2bow(line) for line in dataset]  # convert corpus to BoW format
      >>>
      >>> model = TfidfModel(corpus)  # fit model
      >>> vector = model[corpus[0]]  # apply model to the first corpus document
class_docstr_tok: ["Objects","of","this","class","realize","the","transformation","between","word-document","co-occurrence","matrix","(","int",")","into","a","locally\/globally","weighted","TF-IDF","matrix","(","positive","floats",")",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","import","gensim.downloader","as","api",">",">",">","from","gensim.models","import","TfidfModel",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">",">",">",">","dataset","=","api.load","(","``","text8","''",")",">",">",">","dct","=","Dictionary","(","dataset",")","#","fit","dictionary",">",">",">","corpus","=","[","dct.doc2bow","(","line",")","for","line","in","dataset","]","#","convert","corpus","to","BoW","format",">",">",">",">",">",">","model","=","TfidfModel","(","corpus",")","#","fit","model",">",">",">","vector","=","model","[","corpus","[","0","]","]","#","apply","model","to","the","first","corpus","document"]
docstr: Get the tf-idf representation of an input vector and/or corpus.
  
  bow : {list of (int, int), iterable of iterable of (int, int)}
      Input document in the `sparse Gensim bag-of-words format
      <https://radimrehurek.com/gensim/intro.html#core-concepts>`_,
      or a streamed corpus of such documents.
  eps : float
      Threshold value, will remove all position that have tfidf-value less than `eps`.
  
  Returns
  -------
  vector : list of (int, float)
      TfIdf vector, if `bow` is a single document
  :class:`~gensim.interfaces.TransformedCorpus`
      TfIdf corpus, if `bow` is a corpus.
docstr_tok: ["Get","the","tf-idf","representation","of","an","input","vector","and\/or","corpus",".","bow",":","{","list","of","(","int",",","int",")",",","iterable","of","iterable","of","(","int",",","int",")","}","Input","document","in","the","`","sparse","Gensim","bag-of-words","format","<","https",":","\/\/radimrehurek.com\/gensim\/intro.html","#","core-concepts",">","`","_",",","or","a","streamed","corpus","of","such","documents",".","eps",":","float","Threshold","value",",","will","remove","all","position","that","have","tfidf-value","less","than","`","eps","`",".","Returns","--","--","--","-","vector",":","list","of","(","int",",","float",")","TfIdf","vector",",","if","`","bow","`","is","a","single","document",":","class",":","`","~gensim.interfaces.TransformedCorpus","`","TfIdf","corpus",",","if","`","bow","`","is","a","corpus","."]
code: def __getitem__(self, bow, eps=1e-12):
      """Get the tf-idf representation of an input vector and/or corpus.
  
      bow : {list of (int, int), iterable of iterable of (int, int)}
          Input document in the `sparse Gensim bag-of-words format
          <https://radimrehurek.com/gensim/intro.html#core-concepts>`_,
          or a streamed corpus of such documents.
      eps : float
          Threshold value, will remove all position that have tfidf-value less than `eps`.
  
      Returns
      -------
      vector : list of (int, float)
          TfIdf vector, if `bow` is a single document
      :class:`~gensim.interfaces.TransformedCorpus`
          TfIdf corpus, if `bow` is a corpus.
  
      """
      self.eps = eps
      # if the input vector is in fact a corpus, return a transformed corpus as a result
      is_corpus, bow = utils.is_corpus(bow)
      if is_corpus:
          return self._apply(bow)
  
      # unknown (new) terms will be given zero weight (NOT infinity/huge weight,
      # as strict application of the IDF formula would dictate)
  
      termid_array, tf_array = [], []
      for termid, tf in bow:
          termid_array.append(termid)
          tf_array.append(tf)
  
      tf_array = self.wlocal(np.array(tf_array))
  
      vector = [
          (termid, tf * self.idfs.get(termid))
          for termid, tf in zip(termid_array, tf_array)
          if abs(self.idfs.get(termid, 0.0)) > self.eps
      ]
  
      # and finally, normalize the vector either to unit length, or use a
      # user-defined normalization function
      if self.smartirs:
          n_n = self.smartirs[2]
          if n_n == "n" or (n_n in "ub" and self.pivot is None):
              if self.pivot is not None:
                  _, old_norm = matutils.unitvec(
                      vector, return_norm=True
                  )
              norm_vector = vector
          elif n_n == "c":
              if self.pivot is not None:
                  _, old_norm = matutils.unitvec(
                      vector, return_norm=True
                  )
              else:
                  norm_vector = matutils.unitvec(vector)
          elif n_n == "u":
              _, old_norm = matutils.unitvec(
                  vector, return_norm=True, norm="unique"
              )
          elif n_n == "b":
              old_norm = sum(
                  freq * (self.term_lens[termid] + 1.0)
                  for termid, freq in bow
              )
      else:
          if self.normalize is True:
              self.normalize = matutils.unitvec
          elif self.normalize is False:
              self.normalize = utils.identity
  
          if self.pivot is not None:
              _, old_norm = self.normalize(vector, return_norm=True)
          else:
              norm_vector = self.normalize(vector)
  
      if self.pivot is None:
          norm_vector = [
              (termid, weight)
              for termid, weight in norm_vector
              if abs(weight) > self.eps
          ]
      else:
          pivoted_norm = (
              1 - self.slope
          ) * self.pivot + self.slope * old_norm
          norm_vector = [
              (termid, weight / float(pivoted_norm))
              for termid, weight in vector
              if abs(weight / float(pivoted_norm)) > self.eps
          ]
      return norm_vector
  
file_path: gensim/gensim/models/tfidfmodel.py
imports: import logging
  from functools import partial
  import re
  import numpy
  from gensim import interfaces, matutils, utils
  from gensim.utils import deprecated
label_desc: Use image node_id 5 for calling the TfidfModel obj's underlying member method code with example usage: obj.__getitem__(bow, eps) and returns: norm_vector, self