class_docstr: Dictionary encapsulates the mapping between normalized words and their integer ids.
  
  Notable instance attributes:
  
  Attributes
  ----------
  token2id : dict of (str, int)
      token -> token_id. I.e. the reverse mapping to `self[token_id]`.
  cfs : dict of (int, int)
      Collection frequencies: token_id -> how many instances of this token are contained in the documents.
  dfs : dict of (int, int)
      Document frequencies: token_id -> how many documents contain this token.
  num_docs : int
      Number of documents processed.
  num_pos : int
      Total number of corpus positions (number of processed words).
  num_nnz : int
      Total number of non-zeroes in the BOW matrix (sum of the number of unique
      words per document over the entire corpus).
class_docstr_tok: ["Dictionary","encapsulates","the","mapping","between","normalized","words","and","their","integer","ids",".","Notable","instance","attributes",":","Attributes","--","--","--","--","--","token2id",":","dict","of","(","str",",","int",")","token","-",">","token_id",".","I.e",".","the","reverse","mapping","to","`","self","[","token_id","]","`",".","cfs",":","dict","of","(","int",",","int",")","Collection","frequencies",":","token_id","-",">","how","many","instances","of","this","token","are","contained","in","the","documents",".","dfs",":","dict","of","(","int",",","int",")","Document","frequencies",":","token_id","-",">","how","many","documents","contain","this","token",".","num_docs",":","int","Number","of","documents","processed",".","num_pos",":","int","Total","number","of","corpus","positions","(","number","of","processed","words",")",".","num_nnz",":","int","Total","number","of","non-zeroes","in","the","BOW","matrix","(","sum","of","the","number","of","unique","words","per","document","over","the","entire","corpus",")","."]
docstr: Load a previously stored :class:`~gensim.corpora.dictionary.Dictionary` from a text file.
  
  Mirror function to :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`.
  
  Parameters
  ----------
  fname: str
      Path to a file produced by :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`.
  
  See Also
  --------
  :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`
      Save :class:`~gensim.corpora.dictionary.Dictionary` to text file.
  
  Examples
  --------
  .. sourcecode:: pycon
  
      >>> from gensim.corpora import Dictionary
      >>> from gensim.test.utils import get_tmpfile
      >>>
      >>> tmp_fname = get_tmpfile("dictionary")
      >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
      >>>
      >>> dct = Dictionary(corpus)
      >>> dct.save_as_text(tmp_fname)
      >>>
      >>> loaded_dct = Dictionary.load_from_text(tmp_fname)
      >>> assert dct.token2id == loaded_dct.token2id
docstr_tok: ["Load","a","previously","stored",":","class",":","`","~gensim.corpora.dictionary.Dictionary","`","from","a","text","file",".","Mirror","function","to",":","meth",":","`","~gensim.corpora.dictionary.Dictionary.save_as_text","`",".","Parameters","--","--","--","--","--","fname",":","str","Path","to","a","file","produced","by",":","meth",":","`","~gensim.corpora.dictionary.Dictionary.save_as_text","`",".","See","Also","--","--","--","--",":","meth",":","`","~gensim.corpora.dictionary.Dictionary.save_as_text","`","Save",":","class",":","`","~gensim.corpora.dictionary.Dictionary","`","to","text","file",".","Examples","--","--","--","--","..","sourcecode",":",":","pycon",">",">",">","from","gensim.corpora","import","Dictionary",">",">",">","from","gensim.test.utils","import","get_tmpfile",">",">",">",">",">",">","tmp_fname","=","get_tmpfile","(","``","dictionary","''",")",">",">",">","corpus","=","[","[","``","m\u00e1ma","''",",","``","mele","''",",","``","maso","''","]",",","[","``","ema","''",",","``","m\u00e1","''",",","``","m\u00e1ma","''","]","]",">",">",">",">",">",">","dct","=","Dictionary","(","corpus",")",">",">",">","dct.save_as_text","(","tmp_fname",")",">",">",">",">",">",">","loaded_dct","=","Dictionary.load_from_text","(","tmp_fname",")",">",">",">","assert","dct.token2id","==","loaded_dct.token2id"]
code: def load_from_text(fname):
      """Load a previously stored :class:`~gensim.corpora.dictionary.Dictionary` from a text file.
  
      Mirror function to :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`.
  
      Parameters
      ----------
      fname: str
          Path to a file produced by :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`.
  
      See Also
      --------
      :meth:`~gensim.corpora.dictionary.Dictionary.save_as_text`
          Save :class:`~gensim.corpora.dictionary.Dictionary` to text file.
  
      Examples
      --------
      .. sourcecode:: pycon
  
          >>> from gensim.corpora import Dictionary
          >>> from gensim.test.utils import get_tmpfile
          >>>
          >>> tmp_fname = get_tmpfile("dictionary")
          >>> corpus = [["máma", "mele", "maso"], ["ema", "má", "máma"]]
          >>>
          >>> dct = Dictionary(corpus)
          >>> dct.save_as_text(tmp_fname)
          >>>
          >>> loaded_dct = Dictionary.load_from_text(tmp_fname)
          >>> assert dct.token2id == loaded_dct.token2id
  
      """
      result = Dictionary()
      with utils.open(fname, "rb") as f:
          for lineno, line in enumerate(f):
              line = utils.to_unicode(line)
              if lineno == 0:
                  if line.strip().isdigit():
                      # Older versions of save_as_text may not write num_docs on first line.
                      result.num_docs = int(line.strip())
                      continue
                  else:
                      logging.warning(
                          "Text does not contain num_docs on the first line."
                      )
              try:
                  wordid, word, docfreq = line[:-1].split("\t")
              except Exception:
                  raise ValueError(
                      "invalid line in dictionary file %s: %s"
                      % (fname, line.strip())
                  )
              wordid = int(wordid)
              if word in result.token2id:
                  raise KeyError(
                      "token %s is defined as ID %d and as ID %d"
                      % (word, wordid, result.token2id[word])
                  )
              result.token2id[word] = wordid
              result.dfs[wordid] = int(docfreq)
      return result
  
imports: from collections import defaultdict
  from collections.abc import Mapping
  import logging
  import itertools
  from typing import Optional, List, Tuple
  from gensim import utils
label_desc: Use image node_id 20 for calling the Dictionary obj's underlying member method code with example usage: obj.load_from_text(fname) and returns: result