Is there a way to highlight a span of text?

I need to build a frame which shows a text and for example changes the background of people mentioned in yellow and of places in green. Of course I have the text in a variable and a list of dictionaries with an entry for each span similar to {‘type’: 'person, ‘begin’: 46, ‘end’: 58} where the numbers describe the position in the text string variable.

Any ideas? Thanks a lot and love and happiness to all of Plotly’s community ! :slight_smile:

1 Like

Hi @rjalexander

Have you checked out spaCy ?

1 Like

Wow very interesting thanks a lot. As you have guessed my goal is named entity highlighting on an article text (persons, places and organizations).

I have around 150.000 documents which I have treated with Stanford’s Stanza NLP pipelines and the spans I was referring to are the result of its NER stage.

I wonder if I should be looking for a way to convert my spans to Spacy compatible format or wonder if I could somehow use the Stanza spans within Dash.

In the past I had written a small script to convert Stanza’s NER spans and display them in BRAT but have no frontend skills and therefore no clue as to how I could insert a BRAT like visualizazion in a Dash frame.

Thanks a lot

PS BRAT → brat rapid annotation tool