docstr: Initialize Princeton WordNet Gloss Corpus provided in UFSAC.
  
  see https://github.com/getalp/UFSAC
  When first initializing the corpus the whole UFSAC data is downloaded.
docstr_tok: ["Initialize","Princeton","WordNet","Gloss","Corpus","provided","in","UFSAC",".","see","https",":","\/\/github.com\/getalp\/UFSAC","When","first","initializing","the","corpus","the","whole","UFSAC","data","is","downloaded","."]
code: def __init__(
      self,
      base_path: Optional[Union[str, Path]] = None,
      in_memory: bool = True,
      columns={0: "text", 3: "sense"},
      label_name_map: Optional[Dict[str, str]] = None,
      banned_sentences: Optional[List[str]] = None,
      sample_missing_splits: Union[bool, str] = True,
      use_raganato_ALL_as_test_data: bool = False,
  ) -> None:
      """Initialize Princeton WordNet Gloss Corpus provided in UFSAC.
  
      see https://github.com/getalp/UFSAC
      When first initializing the corpus the whole UFSAC data is downloaded.
      """
      base_path = (
          flair.cache_root / "datasets"
          if not base_path
          else Path(base_path)
      )
  
      dataset_name = "wsd_ufsac"
  
      data_folder = base_path / dataset_name
      original_data_folder = data_folder / "original_data"
  
      # We check if the the UFSAC data has already been downloaded. If not, we download it.
      # Note that this downloads more datasets than just WordNet Gloss Tagged. But the size of the download is only around 190 Mb (around 4.5 Gb unpacked)
      if not original_data_folder.exists():
          # create folder
          data_folder.mkdir(parents=True)
  
          # download data
          import gdown
  
          url = "https://drive.google.com/uc?id=1Oigo3kzRosz2VjyA44vpJZ58tDFyLRMO"
  
          output = data_folder / (dataset_name + ".tar")
  
          gdown.download(url, str(output), quiet=False)
  
          output = data_folder / (dataset_name + ".tar")
          unpack_file(
              file=output, unpack_to=data_folder, mode="tar", keep=False
          )
  
          os.rename(
              data_folder / "ufsac-public-2.1", original_data_folder
          )
  
      if use_raganato_ALL_as_test_data:
          # in this case no test data should be generated by sampling from train data. But if sample_missing_splits is true, the dev set will be sampled.
          if sample_missing_splits:
              sample_missing_splits = "only_dev"
  
          # generate the test file
          test_file = determine_tsv_file(
              filename="raganato_ALL",
              data_folder=data_folder,
              cut_multisense=True,
          )
      else:
          test_file = None
  
      train_file = determine_tsv_file(
          filename="wngt", data_folder=data_folder, cut_multisense=False
      )  # does not have multisense!
  
      super().__init__(
          data_folder=data_folder,
          column_format=columns,
          train_file=train_file,
          test_file=test_file,
          in_memory=in_memory,
          document_separator_token="-DOCSTART-",
          column_delimiter="\t",
          autofind_splits=False,
          label_name_map=label_name_map,
          banned_sentences=banned_sentences,
          sample_missing_splits=sample_missing_splits,
      )
  
imports: import csv
  import logging
  import os
  from pathlib import Path
  from typing import Dict, List, Optional, Union
  import requests
  import flair
  from flair.data import Corpus, MultiCorpus, Sentence
  from flair.datasets.sequence_labeling import ColumnCorpus, MultiFileColumnCorpus
  from flair.file_utils import cached_path, unpack_file
  from flair.splitter import SegtokSentenceSplitter, SentenceSplitter
label_desc: Use image node_id 1 to create a new WSD_WORDNET_GLOSS_TAGGED object from inherited base classes: ColumnCorpus with example: obj = WSD_WORDNET_GLOSS_TAGGED(base_path, in_memory, columns, label_name_map, banned_sentences, sample_missing_splits, use_raganato_ALL_as_test_data)