code: def test_add_documents(self):
      # word vocabulary.
      docs = [["a"], ["a", "b"], ["a", "b", "c"]]
      token2id = {"<pad>": 0, "a": 1, "b": 2, "c": 3, "<unk>": 4}
      vocab = Vocabulary()
      vocab.add_documents(docs)
      vocab.build()
      self.assertEqual(vocab._token2id, token2id)
  
      token2id = {"<pad>": 0, "a": 1, "b": 2, "c": 3}
      vocab = Vocabulary(unk_token=False)
      vocab.add_documents(docs)
      vocab.build()
      self.assertEqual(vocab._token2id, token2id)
  
      token2id = {"<pad>": 0, "<s>": 1, "a": 2, "b": 3, "c": 4}
      vocab = Vocabulary(unk_token=False, specials=("<pad>", "<s>"))
      vocab.add_documents(docs)
      vocab.build()
      self.assertEqual(vocab._token2id, token2id)
  
      token2id = {"a": 0, "b": 1, "c": 2}
      vocab = Vocabulary(unk_token=False, specials=())
      vocab.add_documents(docs)
      vocab.build()
      self.assertEqual(vocab._token2id, token2id)
  
      # char vocabulary.
      docs = ["hoge", "fuga", "bar"]
      vocab = Vocabulary()
      vocab.add_documents(docs)
      vocab.build()
      num_chars = len(set("".join(docs))) + 2
      self.assertEqual(len(vocab._token2id), num_chars)
  
file_path: anago/tests/test_utils.py
imports: import os
  import unittest
  from anago.utils import load_data_and_labels, Vocabulary, download, NERSequence
  from anago.preprocessing import IndexTransformer
label_desc: Use image node_id 1 for calling the TestVocabulary obj's underlying member method code with example usage: obj.test_add_documents() without return types