title: Spacy Romanian language [W036] The component 'entity_ruler' does not have any patterns defined. error
body: <p>After several long months of sneakily following you guys for troubleshooting tips, I finally came across a problem I didn't find a thread on (yet). I know it will probably be something stupid, but I can't wrap it up.</p>
  <p>So here it is: I'm noobing my way around an awesome tutorial (<a href="https://www.youtube.com/watch?v=wpyCzodvO3A" rel="nofollow noreferrer">https://www.youtube.com/watch?v=wpyCzodvO3A</a>) on creating a rudimentary Spacy training module containing an entity ruler and trying to test it. The language I'm working with is Romanian, maybe this has something to do with it. I can create it, load it but when I use it on a text it croaks on me.</p>
  <p>The code below:</p>
  <pre><code>import spacy
  import mysql.connector
  import pandas as pd
  from spacy.lang.ro import Romanian
  from spacy.pipeline import EntityRuler
  import json
  import os
  
  def load_data(file):
      with open(file, &quot;r&quot;, encoding=&quot;utf-8&quot;) as f:
          data =json.load(f)
      return(data)
  
  def generate_better_characters(file):
      data = load_data(file)
      print(len(data))
      new_characters = []
      for item in data:
          new_characters.append(item)
      for item in data:
          item = item.replace(&quot;și&quot;, &quot;&quot;).replace(&quot;si&quot;, &quot;&quot;).replace(&quot;Și&quot;, &quot;&quot;)
          names = item.split()
          for name in names:
              name = name.strip()
              #   Debug
              #print(name)
              new_characters.append(name)
          if &quot;(&quot; in item:
              names = item.split(&quot;(&quot;)
              for name in names:
                  name = name.replace(&quot;)&quot;, &quot;&quot;).strip()
                  new_characters.append(name)
          if &quot;,&quot; in item:
              names = item.split(&quot;,&quot;)
              name = name.replace(&quot;și&quot;, &quot;&quot;).replace(&quot;si&quot;, &quot;&quot;).strip()
              #   Debug
              #print(name)
              if &quot; &quot; in name:
                  new_names = name.split()
                  for x in new_names:
                      new_characters.append(x)
                      #print(x)
              new_characters.apend(name)
      
      
      final_characters = []
      
      titles = [&quot;Dr.&quot;, &quot;Profesorul&quot;, &quot;prof.&quot;, &quot;Prof.&quot;, &quot;Domnul&quot;, &quot;domnul&quot;, &quot;dl.&quot;, &quot;Dl.&quot;, &quot;Doamna&quot;, &quot;doamna&quot;, &quot;dna.&quot;, &quot;domnisoara&quot;, &quot;Domnisoara&quot;, &quot;Dl. si dna.&quot;]
      
      for character in new_characters:
          if &quot;&quot; != character:
              final_characters.append(character)
              for title in titles:
                  titled_char = f&quot;{title} {character}&quot;
                  final_characters.append(titled_char)
      
      print(len(final_characters))
      final_characters = list(set(final_characters))
      print(len(final_characters))
      final_characters.sort()
      return(final_characters)
  
  def create_training_data(file, type):
      data = generate_better_characters(file)
      patterns = []
      for item in data:
          pattern = {
                      &quot;label&quot;: type,
                      &quot;pattern&quot;: item
                      }
          patterns.append(pattern)
      return(patterns)
  
  def generate_rules(patterns):
      nlp = Romanian()
      # Entity ruler is allowed to overwrite existing entries #
      ruler = EntityRuler(nlp)
      ruler.add_patterns(patterns)
      nlp.add_pipe(&quot;entity_ruler&quot;)
      nlp.to_disk(&quot;trained_ner&quot;)
  
  patterns = create_training_data(&quot;C:\\tutorial.json&quot;, &quot;PERSON&quot;)
  generate_rules(patterns)
  
  with open(f&quot;C:\\mltutorial.txt&quot;, &quot;r&quot;, encoding='utf-8') as f:
      text = f.read()
  
  nlp = spacy.load(&quot;trained_ner&quot;)
  doc = nlp(text)
  
  for ent in doc.ents:
      print(ent.text)
  </code></pre>