code: def entities_from_df(
      train_df,
      val_df=None,
      word_column=WORD_COL,
      tag_column=TAG_COL,
      sentence_column=SENT_COL,
      use_char=False,
      val_pct=0.1,
      verbose=1,
  ):
      """
      Load entities from pandas DataFrame
      Args:
        train_df(pd.DataFrame): training data
        val_df(pdf.DataFrame): validation data
        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
        use_char(bool):    If True, data will be preprocessed to use character embeddings  in addition to word embeddings
        verbose (boolean): verbosity
  
      """
      # process dataframe and instantiate NERPreprocessor
      x, y = pp.process_df(
          train_df,
          word_column=word_column,
          tag_column=tag_column,
          sentence_column=sentence_column,
          verbose=verbose,
      )
  
      # get validation set
      if val_df is None:
          x_train, x_valid, y_train, y_valid = train_test_split(
              x, y, test_size=val_pct
          )
      else:
          x_train, y_train = x, y
          (x_valid, y_valid) = pp.process_df(
              val_df,
              word_column=word_column,
              tag_column=tag_column,
              sentence_column=sentence_column,
              verbose=0,
          )
  
      # preprocess and convert to generator
      from .anago.preprocessing import IndexTransformer
  
      p = IndexTransformer(use_char=use_char)
      preproc = NERPreprocessor(p)
      preproc.fit(x_train, y_train)
      from .dataset import NERSequence
  
      trn = NERSequence(x_train, y_train, batch_size=U.DEFAULT_BS, p=p)
      val = NERSequence(x_valid, y_valid, batch_size=U.DEFAULT_BS, p=p)
  
      return (trn, val, preproc)
  
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 4 for calling a global function with example usage: entities_from_df(train_df, val_df, word_column, tag_column, sentence_column, use_char, val_pct, verbose) and returns: trn,  val,  preproc