Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Error while visualizing results without entities extracted #64

Closed
marmg opened this issue Aug 31, 2023 · 0 comments · Fixed by #65
Closed

[Bug] Error while visualizing results without entities extracted #64

marmg opened this issue Aug 31, 2023 · 0 comments · Fixed by #65
Assignees
Labels
bug Something isn't working

Comments

@marmg
Copy link
Collaborator

marmg commented Aug 31, 2023

Summary

Describe the bug
IndexError while visualizing results without entities extracted in the "rel" mode:

File ~/zshot/utils/displacy/relations_render.py:27, in parse_rels(doc)
     25         tokens_span.append((filtered_spans[idx - 1].end, span.start, None))
     26     tokens_span.append((span.start, span.end, span))
---> 27 if filtered_spans[-1].end < len(doc.text):
     28     tokens_span.append((filtered_spans[-1].end, len(doc.text), None))
     30 words = []

IndexError: list index out of range

To Reproduce

import spacy

from zshot import PipelineConfig, displacy
from zshot.relation_extractor import RelationsExtractorZSRC
from zshot.utils.data_models import Relation

nlp = spacy.load("en_core_web_sm")
nlp_config = PipelineConfig(
    relations_extractor=RelationsExtractorZSRC(thr=0.1),
    relations=[
        Relation(name='located in', description="If something like a person, a building, or a company is located in a particular place, like a city, country of any other physical location, it is present or has been built there")
    ]
)
nlp.add_pipe("zshot", config=nlp_config, last=True)

text = "IBM headquarters are located in Armonk."
doc = nlp(text)
displacy.render(doc, style='rel')

Expected behavior
Show sentence without entities and relations

@marmg marmg added the bug Something isn't working label Aug 31, 2023
@marmg marmg self-assigned this Aug 31, 2023
@marmg marmg closed this as completed in #65 Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant