class_docstr: Question-Answering-based Information Extraction
class_docstr_tok: ["Question-Answering-based","Information","Extraction"]
docstr: ```
  Extracts answers from texts
  
  Args:
    texts(list): list of strings
    df(pd.DataFrame): original DataFrame to which columns need to be added
    question_label_pairs(list):  A list of tuples of the form (question, label).
                               Extracted ansewrs to the question will be added as new columns with the
                               specified labels.
                               Example: ('What are the risk factors?', 'Risk Factors')
    min_conf(float):  Answers at or below this confidence value will be set to None in the results
                      Default: 5.0
                      Lower this value to reduce false negatives.
                      Raise this value to reduce false positives.
    return_conf(bool): If True, confidence score of each extraction is included in results
    batch_size(int): batch size. Default: 8
  ```
docstr_tok: ["``","`","Extracts","answers","from","texts","Args",":","texts","(","list",")",":","list","of","strings","df","(","pd.DataFrame",")",":","original","DataFrame","to","which","columns","need","to","be","added","question_label_pairs","(","list",")",":","A","list","of","tuples","of","the","form","(","question",",","label",")",".","Extracted","ansewrs","to","the","question","will","be","added","as","new","columns","with","the","specified","labels",".","Example",":","(","'What","are","the","risk","factors","?","'",",","'Risk","Factors","'",")","min_conf","(","float",")",":","Answers","at","or","below","this","confidence","value","will","be","set","to","None","in","the","results","Default",":","5.0","Lower","this","value","to","reduce","false","negatives",".","Raise","this","value","to","reduce","false","positives",".","return_conf","(","bool",")",":","If","True",",","confidence","score","of","each","extraction","is","included","in","results","batch_size","(","int",")",":","batch","size",".","Default",":","8","``","`"]
code: def extract(
      self,
      texts,
      df,
      question_label_pairs,
      min_conf=DEFAULT_MIN_CONF,
      return_conf=False,
      batch_size=8,
  ):
      """
      ```
      Extracts answers from texts
  
      Args:
        texts(list): list of strings
        df(pd.DataFrame): original DataFrame to which columns need to be added
        question_label_pairs(list):  A list of tuples of the form (question, label).
                                   Extracted ansewrs to the question will be added as new columns with the
                                   specified labels.
                                   Example: ('What are the risk factors?', 'Risk Factors')
        min_conf(float):  Answers at or below this confidence value will be set to None in the results
                          Default: 5.0
                          Lower this value to reduce false negatives.
                          Raise this value to reduce false positives.
        return_conf(bool): If True, confidence score of each extraction is included in results
        batch_size(int): batch size. Default: 8
      ```
      """
      if not isinstance(df, pd.DataFrame):
          raise ValueError("df must be a pandas DataFrame.")
      if len(texts) != df.shape[0]:
          raise ValueError(
              "Number of texts is not equal to the number of rows in the DataFrame."
          )
      # texts = [t.replace("\n", " ").replace("\t", " ") for t in texts]
      texts = [t.replace("\t", " ") for t in texts]
      questions = [q for q, l in question_label_pairs]
      labels = [l for q, l in question_label_pairs]
      self._check_columns(labels, df)
      cols = self._extract(
          questions,
          texts,
          min_conf=min_conf,
          return_conf=return_conf,
          batch_size=batch_size,
      )
      data = list(zip(*cols)) if len(cols) > 1 else cols[0]
      if return_conf:
          labels = twolists(labels, [l + " CONF" for l in labels])
      return df.join(pd.DataFrame(data, columns=labels, index=df.index))
  
imports: from transformers import AutoModelForQuestionAnswering, AutoTokenizer, TFAutoModelForQuestionAnswering
  from whoosh import index, qparser
  from whoosh.fields import *
  from whoosh.qparser import QueryParser
  from ...None import utils
  from ...imports import *
  from ...torch_base import TorchBase
  from ..None import preprocessor
  from ..None import textutils
  from itertools import chain, zip_longest
label_desc: Use image node_id 4 for calling the AnswerExtractor obj's underlying member method code with example usage: obj.extract(texts, df, question_label_pairs, min_conf, return_conf, batch_size) and returns: df