class_docstr: Class that holds a vocabulary for the dataset.
class_docstr_tok: ["Class","that","holds","a","vocabulary","for","the","dataset","."]
docstr: Initialize vocabulary.
  
  Args:
    filename (str): Vocabulary file name.
docstr_tok: ["Initialize","vocabulary",".","Args",":","filename","(","str",")",":","Vocabulary","file","name","."]
code: def __init__(self, filename):
      """Initialize vocabulary.
  
      Args:
        filename (str): Vocabulary file name.
      """
  
      self._id_to_word = []
      self._word_to_id = {}
      self._unk = -1
      self._bos = -1
      self._eos = -1
  
      with tf.io.gfile.GFile(filename) as f:
          idx = 0
          for line in f:
              word_name = line.strip()
              if word_name == "<S>":
                  self._bos = idx
              elif word_name == "</S>":
                  self._eos = idx
              elif word_name == "UNK":
                  self._unk = idx
              if word_name == "!!!MAXTERMID":
                  continue
  
              self._id_to_word.append(word_name)
              self._word_to_id[word_name] = idx
              idx += 1
  
imports: import random
  import numpy
  from textattack.shared.utils import LazyLoader
label_desc: Use image node_id 1 to create a new Vocabulary object from inherited base classes: object with example: obj = Vocabulary(filename)