I keep receiving the error message in the title, and I'm at my wits end.
Officially. Google shows no matches for this phrase: "Cannot add pattern for zero tokens to matcher". When I searched for help on Explosion's support page, I could not find any reference to it either.
I left a request for info. there. It contains some additional information that references a previous post that did not seem relevant here.
But, here is the link if you wish to review it.
Could you help explain the error message to me?
And explain how I might possibly fix it?
The problem? If I run my code (shown below) using their food_patterns.jsonl file, it works as it should. If I run it with my food_patterns_rp.jsonl file, I receive the error message in the title. despite no visual differences that I can detect in the formatting of those files.
Here is the relevant code:
nlp = spacy.load("en_core_web_lg")
ruler = nlp.add_pipe("entity_ruler")
ruler.from_disk("food_patterns_rp.jsonl")
print("This is the decoded recipe:")
print("")
doc = nlp(clean_recipe)
for ent in doc.ents:
print(ent.text, ent.label_)
In short, my app is designed to identify ingredients in a culinary recipe and return a nutritional profile of the recipes. But I cannot create a "patterns" file (the JSONL file that contains a large (10,000+) dictionary of ingredients) that works.
This screen shot below shows the entire Traceback message, though the most relevant part reads as follows:
File "spacy\matcher\matcher.pyx", line 118, in spacy.matcher.matcher.Matcher.add ValueError: [E012] Cannot add pattern for zero tokens to matcher. Key: INGRED
I will assume that no one has time to review my JSONL patterns file.
But here a sample from the working patterns file:
{"label":"INGRED","pattern":[{"lower":"olive"},{"lower":"oil"}]}
Versus a corresponding sample from mine:
{"label": "INGRED", "pattern": [{"lower": "olive"}, {"lower": "oil"}]}
With the exception of some extra spaces, there really is no difference in the formatting of these file that I can find.
Thank you in advance. I welcome all sincere feedback
Robert