Visualizing using markup
item.markup() method combined with
collection.out(its.markedUpText) provides a mechanism to annotate text for visualization. This is completely medium agnostic, which means you can either visualize using HTML, SVG or even the classic unix terminal. Consider the following text:
const text = `Its quarterly profits jumped 76% to $1.13 billion for the three months to December, from $639million of previous year.`; const doc = nlp.readDoc( text );
Highlight the entities in the above text and then see the marked-up text:
doc.entities().each((e) => e.markup()); doc.out(its.markedUpText); // -> Its quarterly profits jumped <mark>76%</mark> to // <mark>$1.13 billion</mark> for the <mark>three months</mark> to // <mark>December</mark>, from <mark>$639million</mark> of <mark>previous year</mark>.
This returned the original text with every entity annotated with the HTML
<mark> tag. This text, when viewed as HTML appears as:
Its quarterly profits jumped 76% to $1.13 billion for the three months to December, from $639million of previous year.
item.markup() accepts two parameters —
endTag. Their default values are <mark> and </mark> respectively.
Similarly it is also possible to highlight items on the console by using color codes to set the values of begin and end tags in the