      assert doc.has_annotation("MORPH")
  
  
  def test_attributeruler_score(nlp, pattern_dicts):
      # initialize with patterns
      ruler = nlp.add_pipe("attribute_ruler")
      ruler.initialize(lambda: [], patterns=pattern_dicts)
      doc = nlp("This is a test.")
      assert doc[2].lemma_ == "the"
 
</s>
def test_attributeruler_init_clear(nlp, pattern_dicts):
    """Test that initialization clears patterns."""
    ruler = nlp.add_pipe("attribute_ruler")
    assert not len(ruler.matcher)
    ruler.add_patterns(pattern_dicts)
    assert len(ruler.matcher)
    ruler.initialize(lambda: [])
    assert not len(ruler.matcher)


      assert doc.has_annotation("MORPH")
  
  
def test_attributeruler_init_clear(nlp, pattern_dicts):
    """Test that initialization clears patterns."""
    ruler = nlp.add_pipe("attribute_ruler")
    assert not len(ruler.matcher)
    ruler.add_patterns(pattern_dicts)
    assert len(ruler.matcher)
    ruler.initialize(lambda: [])
    assert not len(ruler.matcher)


  def test_attributeruler_score(nlp, pattern_dicts):
      # initialize with patterns
      ruler = nlp.add_pipe("attribute_ruler")
      ruler.initialize(lambda: [], patterns=pattern_dicts)
      doc = nlp("This is a test.")
      assert doc[2].lemma_ == "the"
keep keep add keep keep keep keep keep keep
 Clear rule-based components on initialize
spacy/tests/pipeline/test_attributeruler.py