class_docstr: Mapping between words and their integer ids, using a hashing function.
  
  Unlike :class:`~gensim.corpora.dictionary.Dictionary`,
  building a :class:`~gensim.corpora.hashdictionary.HashDictionary` before using it **isn't a necessary step**.
  
  You can start converting words to ids immediately, without training on a corpus.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import HashDictionary
      >>>
      >>> dct = HashDictionary(debug=False)  # needs no training corpus!
      >>>
      >>> texts = [['human', 'interface', 'computer']]
      >>> dct.doc2bow(texts[0])
      [(10608, 1), (12466, 1), (31002, 1)]
class_docstr_tok: ["Mapping","between","words","and","their","integer","ids",",","using","a","hashing","function",".","Unlike",":","class",":","`","~gensim.corpora.dictionary.Dictionary","`",",","building","a",":","class",":","`","~gensim.corpora.hashdictionary.HashDictionary","`","before","using","it","*","*","is","n't","a","necessary","step","*","*",".","You","can","start","converting","words","to","ids","immediately",",","without","training","on","a","corpus",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","HashDictionary",">",">",">",">",">",">","dct","=","HashDictionary","(","debug=False",")","#","needs","no","training","corpus","!",">",">",">",">",">",">","texts","=","[","[","'human","'",",","'interface","'",",","'computer","'","]","]",">",">",">","dct.doc2bow","(","texts","[","0","]",")","[","(","10608",",","1",")",",","(","12466",",","1",")",",","(","31002",",","1",")","]"]
docstr: Collect corpus statistics from a corpus.
  
  Warnings
  --------
  Useful only if `debug=True`, to build the reverse `id=>set(words)` mapping.
  
  Notes
  -----
  This is only a convenience wrapper for calling `doc2bow` on each document with `allow_update=True`.
  
  Parameters
  ----------
  documents : iterable of list of str
      Collection of documents.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import HashDictionary
      >>>
      >>> dct = HashDictionary(debug=True)  # needs no training corpus!
      >>>
      >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
      >>> "sparta" in dct.token2id
      False
      >>> dct.add_documents([["this", "is", "sparta"], ["just", "joking"]])
      >>> "sparta" in dct.token2id
      True
docstr_tok: ["Collect","corpus","statistics","from","a","corpus",".","Warnings","--","--","--","--","Useful","only","if","`","debug=True","`",",","to","build","the","reverse","`","id=",">","set","(","words",")","`","mapping",".","Notes","--","--","-","This","is","only","a","convenience","wrapper","for","calling","`","doc2bow","`","on","each","document","with","`","allow_update=True","`",".","Parameters","--","--","--","--","--","documents",":","iterable","of","list","of","str","Collection","of","documents",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","HashDictionary",">",">",">",">",">",">","dct","=","HashDictionary","(","debug=True",")","#","needs","no","training","corpus","!",">",">",">",">",">",">","corpus","=","[","[","``","m\u00e1ma","''",",","``","mele","''",",","``","maso","''","]",",","[","``","ema","''",",","``","m\u00e1","''",",","``","m\u00e1ma","''","]","]",">",">",">","``","sparta","''","in","dct.token2id","False",">",">",">","dct.add_documents","(","[","[","``","this","''",",","``","is","''",",","``","sparta","''","]",",","[","``","just","''",",","``","joking","''","]","]",")",">",">",">","``","sparta","''","in","dct.token2id","True"]
code: def add_documents(self, documents):
      """Collect corpus statistics from a corpus.
  
      Warnings
      --------
      Useful only if `debug=True`, to build the reverse `id=>set(words)` mapping.
  
      Notes
      -----
      This is only a convenience wrapper for calling `doc2bow` on each document with `allow_update=True`.
  
      Parameters
      ----------
      documents : iterable of list of str
          Collection of documents.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora import HashDictionary
          >>>
          >>> dct = HashDictionary(debug=True)  # needs no training corpus!
          >>>
          >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
          >>> "sparta" in dct.token2id
          False
          >>> dct.add_documents([["this", "is", "sparta"], ["just", "joking"]])
          >>> "sparta" in dct.token2id
          True
  
      """
      for docno, document in enumerate(documents):
          if docno % 10000 == 0:
              logger.info("adding document #%i to %s", docno, self)
          self.doc2bow(
              document, allow_update=True
          )  # ignore the result, here we only care about updating token ids
      logger.info(
          "built %s from %i documents (total %i corpus positions)",
          self,
          self.num_docs,
          self.num_pos,
      )
  
file_path: gensim/gensim/corpora/hashdictionary.py
imports: import logging
  import itertools
  import zlib
  from gensim import utils
label_desc: Use image node_id 8 for calling the HashDictionary obj's underlying member method code with example usage: obj.add_documents(documents) without return types