      assert doc.ents[0].label_ == "HELLO"
      assert doc.ents[1].label_ == "BYE"
  
  
  def test_entity_ruler_existing(nlp, patterns):
      ruler = nlp.add_pipe("entity_ruler")
      ruler.add_patterns(patterns)
      nlp.add_pipe("add_ent", before="entity_ruler")
 
</s>
def test_entity_ruler_init_clear(nlp, patterns):
    """Test that initialization clears patterns."""
    ruler = nlp.add_pipe("entity_ruler")
    ruler.add_patterns(patterns)
    assert len(ruler.labels) == 4
    ruler.initialize(lambda: [])
    assert len(ruler.labels) == 0


      assert doc.ents[0].label_ == "HELLO"
      assert doc.ents[1].label_ == "BYE"
  
  
def test_entity_ruler_init_clear(nlp, patterns):
    """Test that initialization clears patterns."""
    ruler = nlp.add_pipe("entity_ruler")
    ruler.add_patterns(patterns)
    assert len(ruler.labels) == 4
    ruler.initialize(lambda: [])
    assert len(ruler.labels) == 0


  def test_entity_ruler_existing(nlp, patterns):
      ruler = nlp.add_pipe("entity_ruler")
      ruler.add_patterns(patterns)
      nlp.add_pipe("add_ent", before="entity_ruler")
keep keep keep add keep keep keep keep
 Clear rule-based components on initialize
spacy/tests/pipeline/test_entity_ruler.py