this is a code and i ma getting error which is
NameError: name 'pipe' is not defined
NameError: name 'pipe' is not defined
Code:
nlp = spacy.blank('en')
def train_model(train_data):
if 'ner' not in nlp.pipe_names:
ner = nlp.create_pipe('ner')
nlp.add_pipe(ner, last=True)
for _, annotation in train_data:
for ent in annotation['entities']:
ner.add_label(ent[2])
other_pipes = [pipe for pipe in nlp.pipe_names is pipe!='ner']
with nlp.disable_pipes(*other_pipes):
optimizer = nlp.begin_training()
for itn in range(10):
print("starting iteration " + str(itn))
random.shuffle(train_data)
losses = {}
index = 0
for text,annotations in train_data:
try:
nlp.update(
[text], [annotations],drop=0.2,sgd=optimizer,
losses=losses)
except Exception as e:
pass
print(text)
print(losses)