IBM / zshot

Zero and Few shot named entity & relationships recognition
https://ibm.github.io/zshot
MIT License
350 stars 20 forks source link

[Bug] Correctly render relations visualisation in notebooks #35

Closed GabrielePicco closed 2 years ago

GabrielePicco commented 2 years ago

Summary

Describe the bug The relations visualisation should visualise correctly in the notebooks, but the render functions is displaying the HTML as string

To Reproduce Steps to reproduce the behavior:

import spacy
from zshot import PipelineConfig, displacy
from zshot.linker import LinkerSMXM
from zshot.utils.data_models import Entity, Relation
from zshot.relation_extractor import RelationsExtractorZSRC

config = PipelineConfig(
 entities=[
    Entity(name="company", description="The name of a company"),
    Entity(name="location", description="A physical location"),
    Entity(name="chemical compound", description="Any of a large class of chemical compounds in which one or more \
           atoms of carbon are covalently linked to atoms of other elements, most commonly hydrogen, oxygen, or nitrogen")
 ], 
 relations=[
    Relation(name="acronym", description="Is the acronym of"),
    Relation(name="parent", description="Is the parent of someone")
 ], 
 linker=LinkerSMXM(),
 relations_extractor=RelationsExtractorZSRC(),
)
nlp = spacy.blank("en")
nlp.add_pipe("zshot", config=config, last=True)

text = "CH2O2 is a chemical compound similar to Acetamide used in International \
Business Machines Corporation (IBM) to create new materials that act like PAGs."
doc = nlp(text)

Expected behavior

Correctly render the HTML in the notebook