          patterns (list): The patterns to add.
  
          DOCS: https://spacy.io/api/entityruler#add_patterns
          """
          for entry in patterns:
              label = entry["label"]
              if "id" in entry:
                  label = self._create_label(label, entry["id"])
              pattern = entry["pattern"]
              if isinstance(pattern, basestring_):
                  self.phrase_patterns[label].append(self.nlp(pattern))
              elif isinstance(pattern, list):
                  self.token_patterns[label].append(pattern)
              else:
                  raise ValueError(Errors.E097.format(pattern=pattern))
          for label, patterns in self.token_patterns.items():
              self.matcher.add(label, None, *patterns)
          for label, patterns in self.phrase_patterns.items():
              self.phrase_matcher.add(label, None, *patterns)
  
      def _split_label(self, label):
          """Split Entity label into ent_label and ent_id if it contains self.ent_id_sep
  
          RETURNS (tuple): ent_label, ent_id
 
</s> remove         if resized and "nr_class" in self.cfg:
 </s> add         if resized:
            self._resize()

    def _resize(self):
        if "nr_class" in self.cfg: </s> remove         if self.model not in (True, False, None) and resized:
 </s> add         if self.model not in (True, False, None): </s> remove             return self.moves.init_batch(docs)
 </s> add             result = self.moves.init_batch(docs)
            self._resize()
            return result </s> remove         self.model.resize_output(self.moves.n_moves)
 </s> add         self._resize()
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
          patterns (list): The patterns to add.
  
          DOCS: https://spacy.io/api/entityruler#add_patterns
          """
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
        # disable the nlp components after this one in case they hadn't been initialized / deserialised yet
        try:
            current_index = self.nlp.pipe_names.index(self.name)
            subsequent_pipes = [pipe for pipe in self.nlp.pipe_names[current_index + 1:]]
        except ValueError:
            subsequent_pipes = []
        with self.nlp.disable_pipes(*subsequent_pipes):
            for entry in patterns:
                label = entry["label"]
                if "id" in entry:
                    label = self._create_label(label, entry["id"])
                pattern = entry["pattern"]
                if isinstance(pattern, basestring_):
                    self.phrase_patterns[label].append(self.nlp(pattern))
                elif isinstance(pattern, list):
                    self.token_patterns[label].append(pattern)
                else:
                    raise ValueError(Errors.E097.format(pattern=pattern))
            for label, patterns in self.token_patterns.items():
                self.matcher.add(label, None, *patterns)
            for label, patterns in self.phrase_patterns.items():
                self.phrase_matcher.add(label, None, *patterns)
  
      def _split_label(self, label):
          """Split Entity label into ent_label and ent_id if it contains self.ent_id_sep
  
          RETURNS (tuple): ent_label, ent_id
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 Ensure the NER remains consistent after resizing (#4330)

* test and fix for second bug of issue 4042

* fix for first bug in 4042

* crashing test for Issue 4313

* forgot one instance of resize

* remove prints

* undo uncomment

* delete test for 4313 (uses third party lib)

* add fix for Issue 4313

* unit test for 4313 
spacy/pipeline/entityruler.py