I'm trying to retrieve the probability of my spaCy model in assigning the right label to an entity. I have spaCy version 3.0.5.
threshold = 0.5
for i in testing_raw:
doc = nlp_updated(i)
beams = nlp_updated.beam_parse([ doc ], beam_width = 16, beam_density = 0.0001)
entity_scores = defaultdict(float)
for beam in beams:
for score, ents in nlp_updated.entity.moves.get_beam_parses(beam):
for start, end, label in ents:
entity_scores[(start, end, label)] += score
for key in entity_scores:
start, end, label = key
score = entity_scores[key]
if ( score > threshold):
print ('Label: {}, Text: {}, Score: {}'.format(label, doc[start:end], score))
The following line throws this error:
beams = nlp_updated.beam_parse([ doc ], beam_width = 16, beam_density = 0.0001)
AttributeError: 'English' object has no attribute 'beam_parse'
Is this because spaCy version 3 doesn't consider beam_parse
? If so, how can I do this in this version of spaCy as I can't seem to find anything in the documentation?