docstr: Initialize Tweeki Entity Linking corpus.
  
  The dataset got introduced in "Tweeki:
  Linking Named Entities on Twitter to a Knowledge Graph" Harandizadeh,
  Singh. The data consits of tweets with manually annotated wikipedia
  links. If you call the constructor the first time the dataset gets
  automatically downloaded and transformed in tab-separated column
  format.
  
  Parameters
  ----------
  base_path : Union[str, Path], optional
      Default is None, meaning that corpus gets auto-downloaded and loaded. You can override this
      to point to a different folder but typically this should not be necessary.
  in_memory: bool
      If True, keeps dataset in memory giving speedups in training.
docstr_tok: ["Initialize","Tweeki","Entity","Linking","corpus",".","The","dataset","got","introduced","in","``","Tweeki",":","Linking","Named","Entities","on","Twitter","to","a","Knowledge","Graph","''","Harandizadeh",",","Singh",".","The","data","consits","of","tweets","with","manually","annotated","wikipedia","links",".","If","you","call","the","constructor","the","first","time","the","dataset","gets","automatically","downloaded","and","transformed","in","tab-separated","column","format",".","Parameters","--","--","--","--","--","base_path",":","Union","[","str",",","Path","]",",","optional","Default","is","None",",","meaning","that","corpus","gets","auto-downloaded","and","loaded",".","You","can","override","this","to","point","to","a","different","folder","but","typically","this","should","not","be","necessary",".","in_memory",":","bool","If","True",",","keeps","dataset","in","memory","giving","speedups","in","training","."]
code: def __init__(
      self,
      base_path: Optional[Union[str, Path]] = None,
      in_memory: bool = True,
      **corpusargs,
  ) -> None:
      """Initialize Tweeki Entity Linking corpus.
  
      The dataset got introduced in "Tweeki:
      Linking Named Entities on Twitter to a Knowledge Graph" Harandizadeh,
      Singh. The data consits of tweets with manually annotated wikipedia
      links. If you call the constructor the first time the dataset gets
      automatically downloaded and transformed in tab-separated column
      format.
  
      Parameters
      ----------
      base_path : Union[str, Path], optional
          Default is None, meaning that corpus gets auto-downloaded and loaded. You can override this
          to point to a different folder but typically this should not be necessary.
      in_memory: bool
          If True, keeps dataset in memory giving speedups in training.
      """
      base_path = (
          flair.cache_root / "datasets"
          if not base_path
          else Path(base_path)
      )
  
      # this dataset name
      dataset_name = self.__class__.__name__.lower()
  
      data_folder = base_path / dataset_name
  
      tweeki_gold_el_path = "https://raw.githubusercontent.com/ucinlp/tweeki/main/data/Tweeki_gold/Tweeki_gold"
      corpus_file_name = "tweeki_gold.txt"
      parsed_dataset = data_folder / corpus_file_name
  
      # download and parse data if necessary
      if not parsed_dataset.exists():
          original_file_path = cached_path(
              f"{tweeki_gold_el_path}", Path("datasets") / dataset_name
          )
  
          with open(original_file_path, encoding="utf-8") as read, open(
              parsed_dataset, "w", encoding="utf-8"
          ) as write:
              line = read.readline()
              while line:
                  if line.startswith("#"):
                      out_line = ""
                  elif line == "\n":  # tweet ends
                      out_line = "\n-DOCSTART-\n\n"
                  else:
                      line_list = line.split("\t")
                      out_line = line_list[1] + "\t"
                      if line_list[3] == "-\n":  # no wiki name
                          out_line += "O\n"
                      else:
                          out_line += (
                              line_list[2][:2]
                              + line_list[3]
                              .split("|")[0]
                              .replace(" ", "_")
                              + "\n"
                          )
                  write.write(out_line)
                  line = read.readline()
  
          os.rename(
              original_file_path, str(original_file_path) + "_original"
          )
  
      super().__init__(
          data_folder,
          column_format={0: "text", 1: "nel"},
          train_file=corpus_file_name,
          in_memory=in_memory,
          **corpusargs,
      )
  
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 NEL_ENGLISH_TWEEKI object from inherited base classes: ColumnCorpus with example: obj = NEL_ENGLISH_TWEEKI(base_path, in_memory)