Closed sohilsshah91 closed 5 years ago
This is an issue with the naming of your label. I could reproduce your issue with Label = "Indications"
and in the train data "Indication"
. Note the missing "s" at the end. Name both the same way to fix this issue.
Thank you. It solved my issue.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
#2573 Reference: Issue pertaining to custom Named Entity Recognition Label with spaCy
I have referred the above issue #2573 and also spaCy NER adding custom label. I have used the following type of training data format: train_data= [('The Prostate Cancer is a killer',{'entities':[(4,9,'Custom_Label_Name') ] } ), ('The Prostate Cancer Ovarian Cancer too', {'entities': [(4, 19, 'Custom_Label_Name'), (20, 34, 'Custom_Label_Name')]})] as shown in spaCy's documentation and the exact same code apart from label name changed as shared. However I am getting the following error: KeyError: "[E022] Could not find a transition with the name 'U-Indication' in the NER model."
What could I be doing wrong?
Code for reference is as below:
` import plac import random from pathlib import Path import spacy from spacy.util import minibatch, compounding
Label = "Indications" @plac.annotations( model=("Model name. Defaults to blank 'en' model.", "option", "m", str), new_model_name=("New model name for model meta.", "option", "nm", str), output_dir=("Optional output directory", "option", "o", Path), n_iter=("Number of training iterations", "option", "n", int), ) def main(model=None, new_model_name="indication", output_dir=None, n_iter=10): """Set up the pipeline and entity recognizer, and train the new entity.""" random.seed(0) if model is not None: nlp = spacy.load(model) # load existing spaCy model print("Loaded model '%s'" % model) else: nlp = spacy.blank("en") # create blank Language class print("Created blank 'en' model")
Add entity recognizer to model if it's not in the pipeline
`
Your Environment