docstr: Convert a tokenized sentence into column format.
  
  Args:
      sentence: Flair Sentence object containing a tokenized post title or comment thread
      links: array containing information about the starting and ending position of an entity mention, as well as its corresponding wiki tag
      outfile: file, to which the output is written
docstr_tok: ["Convert","a","tokenized","sentence","into","column","format",".","Args",":","sentence",":","Flair","Sentence","object","containing","a","tokenized","post","title","or","comment","thread","links",":","array","containing","information","about","the","starting","and","ending","position","of","an","entity","mention",",","as","well","as","its","corresponding","wiki","tag","outfile",":","file",",","to","which","the","output","is","written"]
code: def _text_to_cols(self, sentence: Sentence, links: list, outfile):
      """Convert a tokenized sentence into column format.
  
      Args:
          sentence: Flair Sentence object containing a tokenized post title or comment thread
          links: array containing information about the starting and ending position of an entity mention, as well as its corresponding wiki tag
          outfile: file, to which the output is written
      """
      for i in range(len(sentence)):
          # If there are annotated entity mentions for given post title or a comment thread
          if links:
              # Keep track which is the correct corresponding entity link, in cases where there is >1 link in a sentence
              link_index = [
                  j
                  for j, v in enumerate(links)
                  if (
                      sentence[i].start_position >= v[0]
                      and sentence[i].end_position <= v[1]
                  )
              ]
              # Write the token with a corresponding tag to file
              try:
                  if any(
                      sentence[i].start_position == v[0]
                      and sentence[i].end_position == v[1]
                      for j, v in enumerate(links)
                  ):
                      outfile.writelines(
                          sentence[i].text
                          + "\tS-"
                          + links[link_index[0]][2]
                          + "\n"
                      )
                  elif any(
                      sentence[i].start_position == v[0]
                      and sentence[i].end_position != v[1]
                      for j, v in enumerate(links)
                  ):
                      outfile.writelines(
                          sentence[i].text
                          + "\tB-"
                          + links[link_index[0]][2]
                          + "\n"
                      )
                  elif any(
                      sentence[i].start_position >= v[0]
                      and sentence[i].end_position <= v[1]
                      for j, v in enumerate(links)
                  ):
                      outfile.writelines(
                          sentence[i].text
                          + "\tI-"
                          + links[link_index[0]][2]
                          + "\n"
                      )
                  else:
                      outfile.writelines(sentence[i].text + "\tO\n")
              # IndexError is raised in cases when there is exactly one link in a sentence, therefore can be dismissed
              except IndexError:
                  pass
  
          # If a comment thread or a post title has no entity link, all tokens are assigned the O tag
          else:
              outfile.writelines(sentence[i].text + "\tO\n")
  
          # Prevent writing empty lines if e.g. a quote comes after a dot or initials are tokenized
          # incorrectly, in order to keep the desired format (empty line as a sentence separator).
          try:
              if (
                  (sentence[i].text in {".", "!", "?", "!*"})
                  and (
                      sentence[i + 1].text
                      not in {'"', "“", "'", "''", "!", "?", ";)", "."}
                  )
                  and ("." not in sentence[i - 1].text)
              ):
                  outfile.writelines("\n")
          except IndexError:
              # Thrown when the second check above happens, but the last token of a sentence is reached.
              # Indicates that the EOS punctuaion mark is present, therefore an empty line needs to be written below.
              outfile.writelines("\n")
  
      # If there is no punctuation mark indicating EOS, an empty line is still needed after the EOS
      if sentence[-1].text not in {".", "!", "?"}:
          outfile.writelines("\n")
  
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 2 for calling the NEL_ENGLISH_REDDIT obj's underlying member method code with example usage: obj._text_to_cols(sentence, links, outfile) without return types