Skip to content

Visualization of nested spans #42

Description

@phlobo

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions