Skip to content

Error in merge_phrases  #975

@ghost

Description

Got such error

"Error calculating span: Can't find start"

When i tried to put such text

"What factors is iShares 1-3 Year Credit Bond exposed with"

code of merge_phrases

def merge_phrases(matcher, doc, i, matches):
    '''
    Merge a phrase. We have to be careful here because we'll change the token indices.
    To avoid problems, merge all the phrases once we're called on the last match.
    '''
    if i != len(matches)-1:
        return None
    spans = [(ent_id, label, doc[start : end]) for ent_id, label, start, end in matches]
    for ent_id, label, span in spans:
        span.merge('NNP' if label else span.root.tag_, span.text, settings.nlp.vocab.strings[label])

Metadata

Metadata

Assignees

No one assigned

    Labels

    usageGeneral spaCy usage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions