Display NER tags with SpaCy displacy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import spacy | |
from spacy import displacy | |
nlp = spacy.blank('ja') | |
raw_text = "私は東京に行きます。その後、千葉にも行きます。" | |
doc = nlp.make_doc(raw_text) | |
spans = [[2,4,"LOC"],[14,16,"LOC"]] | |
ents = [] | |
for span_start, span_end, label in spans: | |
ent = doc.char_span(span_start, span_end, label=label) | |
if ent is None: | |
continue | |
ents.append(ent) | |
doc.ents = ents | |
displacy.render(doc, style="ent", jupyter=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment