code: def test_doc2id(self):
      # word ids.
      docs = [["a"], ["a", "b"], ["a", "b", "c"]]
      vocab = Vocabulary()
      vocab.add_documents(docs)
      vocab.build()
      another_doc = ["a", "b", "c", "d"]
      doc_ids = vocab.doc2id(another_doc)
      self.assertEqual(doc_ids, [1, 2, 3, 4])
  
      # char_ids.
      docs = ["hoge", "fuga", "bar"]
      vocab = Vocabulary()
      vocab.add_documents(docs)
      vocab.build()
      doc_ids = vocab.doc2id(docs[0])
      correct = [vocab.token_to_id(c) for c in docs[0]]
      self.assertEqual(doc_ids, correct)
  
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 2 for calling the TestVocabulary obj's underlying member method code with example usage: obj.test_doc2id() without return types