explosion / explosion/spacy-streamlit

Visualization of nested spans

Open
#42 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
863
Forks
113
PR merge metrics
No merged PRs in 30d

Description

Dear all,

I'm trying to use the new span visualizer to display some custom, nested spans predicted by spancat.
This is my code:

```
MODEL_PATH = # ...
DEFAULT_TEXT = """Cetuximab ist ein monoklonaler Antikörper, der gegen den epidermalen Wachstumsfaktorrezeptor (EGFR) gerichtet ist und \
dient zur Therapie des fortgeschrittenen kolorektalen Karzinoms zusammen mit Irinotecan oder in Kombination mit FOLFOX bzw. \
allein nach Versagen einer Behandlung mit Oxaliplatin und Irinotecan."""

st.set_page_config(layout="wide")

text = st.text_area("Text to analyze", DEFAULT_TEXT)
doc = process_text(MODEL_PATH, text)

visualize_spans(doc, spans_key="snomed", displacy_options=
{"colors": {
"Clinical_Drug": "#99FF99", "External_Substance" : "#CCFFCC", "Nutrient_or_Body_Substance" : "#E5FFCC",
"Therapeutic" : "#66B2FF", "Diagnostic" : "#CCE5FF",
"Other_Finding" : "#FFE5CC", "Diagnosis_or_Pathology" : "#FFCCCC"}} )
```
![myapp](https://user-images.githubusercontent.com/1756262/190090478-a44fdd13-7bb9-418c-ab5c-038af8d8426f.PNG)

The nested spans are all shown on the same line, which makes it very hard to read.
I learned from the feature on LinkedIn, where a video was shown with nested spans nicely displayed.

![demo](https://user-images.githubusercontent.com/1756262/190090239-aa3f7d48-4f7b-48d2-ac15-268fe8cf1e54.PNG)

How can I achieve this behavior? Do I need to pass some other options?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.