title: What is the order of matching for similar patterns with different labels in spaCy's EntityRuler?
body: <p>I am trying to add an EntityRuler pipeline into an existing statistical NER model to better handle more structured entity types like numbers, age and money.</p>
  
  <p>However, some of these numerical patterns may be quite similar or have significant overlap with one another, especially if we have a mix of general and more specific patterns. An example of a problem that I am facing is as follows:</p>
  
  <pre><code>    {"label": "NUMBER", "pattern": [{"LIKE_NUM": true}]}
      {"label": "AGE", "pattern": {"TEXT": {"REGEX": "^(1[0-4]|[1-9])?[0-9]$"}}]}
  </code></pre>
  
  <p>I have one rather general pattern that simply uses the <code>LIKE_NUM</code> token attribute to label a generic <code>NUMBER</code> entity; and another more specific pattern using regex to match numbers from 0 to 149 to be of entity type <code>AGE</code>. When I pass in the sentence <code>I am 20</code>, I want the EntityRuler to check against the more specific pattern first before moving on to more general patterns, such that it returns <code>AGE</code> as the label in this case, rather than labelling it as a generic <code>NUMBER</code>.  </p>
  
  <p>I tried rearranging the order of the patterns in my <code>patterns.jsonl</code> file to test if the order of adding the patterns into the pipeline somehow affects the priority assigned to the pattern. However, both cases returned the more generic <code>NUMBER</code> label. </p>
  
  <p>Just to see what would happen, I fed in the sentence <code>I am 20 1 2 01 123 1410 999 001 10 51 001 010 149 150 151</code> and got this result consistently -
  <code>Ents: [('20', 'NUMBER'), ('1', 'AGE'), ('2', 'NUMBER'), ('01', 'NUMBER'), ('123', 'NUMBER'), ('1410', 'NUMBER'), ('999', 'NUMBER'), ('001', 'NUMBER'), ('10', 'AGE'), ('51', 'AGE'), ('001', 'NUMBER'), ('010', 'NUMBER'), ('149', 'NUMBER'), ('150', 'NUMBER'), ('151.', 'NUMBER')]</code>, which seemed to arbitrarily assign <code>AGE</code> or <code>NUMBER</code> to values from 0 to 149.</p>
  
  <p>This raises 2 questions that I hope someone could help to answer:</p>
  
  <ol>
  <li>How / in what order exactly does the EntityRuler go through each of the added patterns?</li>
  <li>Would it be better practice in such NER tasks to avoid having such general umbrella patterns/labels altogether? Or is the issue more of overlapping/similar patterns?</li>
  </ol>