Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.03 KB

README.md

File metadata and controls

35 lines (29 loc) · 1.03 KB

displacyr

A micro-package for R that visualizes, in the terminal, entities in text parsed with spacyr.

Styled terminal output uses the crayon package.

Installation

devtools::install_github("weihuangwong/displacyr")

Usage

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")