A micro-package for R that visualizes, in the terminal, entities in text parsed with spacyr.
Styled terminal output uses the crayon package.
devtools::install_github("weihuangwong/displacyr")
spacyr
and crayon
must be installed and working. Given a character string txt
,
library(displacyr)
library(spacyr)
spacy_initialize()
txt <- "Kenneth Benoit is currently Professor of Computational Social
Science in the Department of Methodology at the London School of
Economics and Political Science. He has previously held positions in
the Department of Political Science at Trinity College Dublin and at
the Central European University (Budapest)."
txt <- gsub("\n", " ", txt)
spacy_parse
it with additional_attributes = "whitespace_"
parsed <- spacy_parse(txt, additional_attributes = "whitespace_")
and then call display_ent
on the parsed object
display_ent(parsed, deco = "yellow")