class_docstr: Adds message features based on regex expressions.
class_docstr_tok: ["Adds","message","features","based","on","regex","expressions","."]
docstr: Updates already known patterns with new patterns extracted from data.
  
  New patterns should always be added to the end of the existing
  patterns and the order of the existing patterns should not be disturbed.
  
  Args:
      new_patterns: Patterns extracted from training data and to be merged with
          known patterns.
docstr_tok: ["Updates","already","known","patterns","with","new","patterns","extracted","from","data",".","New","patterns","should","always","be","added","to","the","end","of","the","existing","patterns","and","the","order","of","the","existing","patterns","should","not","be","disturbed",".","Args",":","new_patterns",":","Patterns","extracted","from","training","data","and","to","be","merged","with","known","patterns","."]
code: def _merge_new_patterns(
      self, new_patterns: List[Dict[Text, Text]]
  ) -> None:
      """Updates already known patterns with new patterns extracted from data.
  
      New patterns should always be added to the end of the existing
      patterns and the order of the existing patterns should not be disturbed.
  
      Args:
          new_patterns: Patterns extracted from training data and to be merged with
              known patterns.
      """
      pattern_name_index_map = {
          pattern["name"]: index
          for index, pattern in enumerate(self.known_patterns)
      }
      for extra_pattern in new_patterns:
          new_pattern_name = extra_pattern["name"]
  
          # Some patterns may have just new examples added
          # to them. These do not count as additional pattern.
          if new_pattern_name in pattern_name_index_map:
              self.known_patterns[
                  pattern_name_index_map[new_pattern_name]
              ]["pattern"] = extra_pattern["pattern"]
          else:
              self.known_patterns.append(extra_pattern)
  
imports: from __future__ import annotations
  import logging
  import re
  from typing import Any, Dict, List, Optional, Text, Tuple, Type
  import numpy
  import scipy.sparse
  from rasa.nlu.tokenizers.tokenizer import Tokenizer
  import rasa.shared.utils.io
  import rasa.utils.io
  import rasa.nlu.utils.pattern_utils
  from rasa.engine.graph import ExecutionContext, GraphComponent
  from rasa.engine.recipes.default_recipe import DefaultV1Recipe
  from rasa.engine.storage.resource import Resource
  from rasa.engine.storage.storage import ModelStorage
  from rasa.nlu.constants import TOKENS_NAMES
  from rasa.nlu.featurizers.sparse_featurizer.sparse_featurizer import SparseFeaturizer
  from rasa.shared.nlu.constants import TEXT, RESPONSE, ACTION_TEXT
  from rasa.shared.nlu.training_data.training_data import TrainingData
  from rasa.shared.nlu.training_data.message import Message
label_desc: Use image node_id 5 for calling the RegexFeaturizer obj's underlying member method code with example usage: obj._merge_new_patterns(new_patterns) without return types