code: def add_extracted_features_for_sentence(
      sentence, extracted_features, task_type=None, sentence_type=None
  ):
      """Add the extracted features for a sentence.
  
      Note this also modifies the input array in-place.
  
      :param sentence: The sentence to extract features from.
      :type sentence: str
      :param extracted_features: The list of extracted features.
      :type extracted_features: list
      :param task_type: The type of task to be performed.
      :type task_type: str
      :param sentence_type: The type of sentence to be processed.
      :type sentence_type: str
      :return: The list of extracted features.
      :rtype: list
      """
      global nlp
      if nlp is None:
          nlp = spacy.load("en_core_web_sm")
          ts = termset("en")
          nlp.add_pipe(
              "negex", config={"neg_termset": ts.get_patterns()}
          )
      doc = nlp(sentence)
      positive_negative_count = exts.positive_negative_word_count(doc)
      named_persons = exts.get_named_persons(doc)
      neg_words_and_entities = exts.detect_negation_words_and_entities(
          doc
      )
      sentence_length = len(sentence)
      features = [
          positive_negative_count["positive_word_count"],
          positive_negative_count["negative_word_count"],
          neg_words_and_entities["negation_words"],
          neg_words_and_entities["negated_entities"],
          len(named_persons),
          sentence_length,
      ]
  
      if task_type == ModelTask.QUESTION_ANSWERING:
          features.append(get_average_depth(doc))
          features.append(get_max_depth(doc))
  
      if sentence_type == "QUESTION":
          question_type = get_question_type(sentence)
          features.append(question_type)
  
      # TODO: This extractor seems to be very slow:
      # mf_count = exts.get_male_female_words_count(doc)
  
      extracted_features.extend(features)
  
file_path: responsible-ai-toolbox/responsibleai_text/responsibleai_text/utils/feature_extractors.py
imports: import re
  from typing import List, Optional, Union
  import pandas
  import spacy
  from negspacy.termsets import termset
  from tqdm import tqdm
  from nlp_feature_extractors import attribute_extractors
  from responsibleai_text.common.constants import ModelTask, QuestionAnsweringFields
label_desc: Use image node_id 4 for calling a global function with example usage: add_extracted_features_for_sentence(sentence, extracted_features, task_type, sentence_type) without return types