class_docstr: Generate a vocabulary from the tokenized training data of a corpus.
  
  :param corpus: The :class:`src.data_new.Corpus` to generate the vocabulary from.
  :param name: Name of the vocabulary.
  :param general_tokens: General tokens.
  :param background_tokens: Background tokens.
  :param year_range: Range of years (inclusive) to generate tokens for.
  :param min_token_count: The minimum number of occurances of a token to be included
      in the vocabulary.
  :param min_token_count_field: Field-specific minimum token counts.
docstr: Filters the tokens by count, sorts them lexicographically for each source,
  and computes the voculary with the field labels as categories.
docstr_tok: ["Filters","the","tokens","by","count",",","sorts","them","lexicographically","for","each","source",",","and","computes","the","voculary","with","the","field","labels","as","categories","."]
code: def vocab(self) -> pd.DataFrame:
      """Filters the tokens by count, sorts them lexicographically for each source,
      and computes the voculary with the field labels as categories.
      """
  
      general = pd.DataFrame(
          {"TOKEN": self.general_tokens, "CATEGORY": "GENERAL"}
      )
      background = pd.DataFrame(
          {"TOKEN": self.background_tokens, "CATEGORY": "BACKGROUND"}
      )
      month = pd.DataFrame(
          {
              "TOKEN": [f"MONTH_{i}" for i in range(1, 13)],
              "CATEGORY": "MONTH",
          }
      )
      year = pd.DataFrame(
          {
              "TOKEN": [
                  f"YEAR_{i}"
                  for i in range(
                      self.year_range[0], self.year_range[1] + 1
                  )
              ],
              "CATEGORY": "YEAR",
          }
      )
  
      vocab_parts = [general, background, month, year]
  
      def sort_key(x: str) -> Tuple[Union[str, int], ...]:
          def maybe_to_int(y: str) -> Union[str, int]:
              return int(y) if y.isdigit() else y
  
          return tuple(maybe_to_int(y) for y in x.split("_"))
  
      for source in self.corpus.sources:
          token_counts = self.token_counts(source)
          for label in source.field_labels():
              counts = token_counts[label]
              min_count = self.min_token_count_field.get(
                  label, self.min_token_count
              )
              tokens = [k for k, v in counts.items() if v >= min_count]
              tokens.sort(key=sort_key)
              tokens_df = pd.DataFrame(
                  {"TOKEN": tokens, "CATEGORY": label}
              )
              vocab_parts.append(tokens_df)
  
      return pd.concat(vocab_parts, ignore_index=True).rename_axis(
          index="ID"
      )
  
imports: from dataclasses import dataclass, field
  from functools import cached_property
  from typing import TYPE_CHECKING, Dict, List, Tuple, Union, cast
  import dask
  import pandas
  from .decorators import save_pickle, save_tsv
  from .serialize import DATA_ROOT
  from .sources.base import TokenSource
label_desc: Use image node_id 1 for calling the CorpusVocabulary obj's underlying member method code with example usage: obj.vocab() and returns: pd, tuple, unknown