class_docstr: A single QA candidate answer.
docstr: Extract from the clear_text a window that contains the answer and (usually) some amount of text on either
  side of the answer. Useful for cases where the answer and its surrounding context needs to be
  displayed in a UI. If the self.context_window_size is smaller than the extracted answer, it will be
  enlarged so that it can contain the answer
  
  :param context_window_size: The size of the context window to be generated. Note that the window size may be increased if the answer is longer.
  :param clear_text: The text from which the answer is extracted
  :return:
docstr_tok: ["Extract","from","the","clear_text","a","window","that","contains","the","answer","and","(","usually",")","some","amount","of","text","on","either","side","of","the","answer",".","Useful","for","cases","where","the","answer","and","its","surrounding","context","needs","to","be","displayed","in","a","UI",".","If","the","self.context_window_size","is","smaller","than","the","extracted","answer",",","it","will","be","enlarged","so","that","it","can","contain","the","answer",":","param","context_window_size",":","The","size","of","the","context","window","to","be","generated",".","Note","that","the","window","size","may","be","increased","if","the","answer","is","longer",".",":","param","clear_text",":","The","text","from","which","the","answer","is","extracted",":","return",":"]
code: def _create_context_window(self, context_window_size, clear_text):
      """
      Extract from the clear_text a window that contains the answer and (usually) some amount of text on either
      side of the answer. Useful for cases where the answer and its surrounding context needs to be
      displayed in a UI. If the self.context_window_size is smaller than the extracted answer, it will be
      enlarged so that it can contain the answer
  
      :param context_window_size: The size of the context window to be generated. Note that the window size may be increased if the answer is longer.
      :param clear_text: The text from which the answer is extracted
      :return:
      """
      if self.offset_answer_start == 0 and self.offset_answer_end == 0:
          return "", 0, 0
      else:
          # If the extracted answer is longer than the context_window_size,
          # we will increase the context_window_size
          len_ans = self.offset_answer_end - self.offset_answer_start
          context_window_size = max(context_window_size, len_ans + 1)
  
          len_text = len(clear_text)
          midpoint = int(len_ans / 2) + self.offset_answer_start
          half_window = int(context_window_size / 2)
          window_start_ch = midpoint - half_window
          window_end_ch = midpoint + half_window
  
          # if we have part of the context window overlapping the start or end of the passage,
          # we'll trim it and use the additional chars on the other side of the answer
          overhang_start = max(0, -window_start_ch)
          overhang_end = max(0, window_end_ch - len_text)
          window_start_ch -= overhang_end
          window_start_ch = max(0, window_start_ch)
          window_end_ch += overhang_start
          window_end_ch = min(len_text, window_end_ch)
      window_str = clear_text[window_start_ch:window_end_ch]
      return window_str, window_start_ch, window_end_ch
  
imports: from typing import List, Any
  from abc import ABC
  import logging
label_desc: Use image node_id 5 for calling the QACandidate obj's underlying member method code with example usage: obj._create_context_window(context_window_size, clear_text) and returns: window_str,  window_start_ch,  window_end_ch, str,  int,  int