code: def entities_from_txt(
      train_filepath,
      val_filepath=None,
      use_char=False,
      word_column=WORD_COL,
      tag_column=TAG_COL,
      sentence_column=SENT_COL,
      data_format="conll2003",
      encoding=None,
      val_pct=0.1,
      verbose=1,
  ):
      """
      Loads sequence-labeled data from comma or tab-delmited text file.
      Format of file is either the CoNLL2003 format or Groningen Meaning
      Bank (GMB) format - specified with data_format parameter.
  
      In both formats, each word appars on a separate line along with
      its associated tag (or label).
      The last item on each line should be the tag or label assigned to word.
  
      In the CoNLL2003 format, there is an empty line after
      each sentence.  In the GMB format, sentences are deliniated
      with a third column denoting the Sentence ID.
  
  
  
      More information on CoNLL2003 format:
         https://www.aclweb.org/anthology/W03-0419
  
      CoNLL Example (each column is typically separated by space or tab)
      and  no column headings:
  
         Paul	B-PER
         Newman	I-PER
         is	O
         a	O
         great	O
         actor	O
         !	O
  
      More information on GMB format:
      Refer to ner_dataset.csv on Kaggle here:
         https://www.kaggle.com/abhinavwalia95/entity-annotated-corpus/version/2
  
      GMB example (each column separated by comma or tab)
      with column headings:
  
        SentenceID   Word     Tag
        1            Paul     B-PER
        1            Newman   I-PER
        1            is       O
        1            a        O
        1            great    O
        1            actor    O
        1            !        O
  
  
      Args:
          train_filepath(str): file path to training CSV
          val_filepath (str): file path to validation dataset
          use_char(bool):    If True, data will be preprocessed to use character embeddings in addition to word embeddings
          word_column(str): name of column containing the text
          tag_column(str): name of column containing lael
          sentence_column(str): name of column containing Sentence IDs
          data_format(str): one of colnll2003 or gmb
                            word_column, tag_column, and sentence_column
                            ignored if 'conll2003'
          encoding(str): the encoding to use.  If None, encoding is discovered automatically
          val_pct(float): Proportion of training to use for validation.
          verbose (boolean): verbosity
      """
  
      # set dataframe converter
      if data_format == "gmb":
          data_to_df = pp.gmb_to_df
      else:
          data_to_df = pp.conll2003_to_df
          word_column, tag_column, sentence_column = (
              WORD_COL,
              TAG_COL,
              SENT_COL,
          )
  
      # detect encoding
      if encoding is None:
          with open(train_filepath, "rb") as f:
              encoding = TU.detect_encoding(f.read())
              U.vprint(
                  "detected encoding: %s (if wrong, set manually)"
                  % (encoding),
                  verbose=verbose,
              )
  
      # create dataframe
      train_df = data_to_df(train_filepath, encoding=encoding)
  
      val_df = (
          None
          if val_filepath is None
          else data_to_df(val_filepath, encoding=encoding)
      )
      return entities_from_df(
          train_df,
          val_df=val_df,
          word_column=word_column,
          tag_column=tag_column,
          sentence_column=sentence_column,
          use_char=use_char,
          val_pct=val_pct,
          verbose=verbose,
      )
  
file_path: ktrain/ktrain/text/ner/data.py
imports: from ...None import utils
  from ...imports import *
  from ..None import textutils
  from .None import preprocessor
  from .preprocessor import NERPreprocessor
label_desc: Use image node_id 3 for calling a global function with example usage: entities_from_txt(train_filepath, val_filepath, use_char, word_column, tag_column, sentence_column, data_format, encoding, val_pct, verbose) and returns: entities_from_df