# Spans not displayed in classification view

**URL:** <https://support.prodi.gy/t/spans-not-displayed-in-classification-view/2168>\
**Category:** Uncategorized\
**Tags:** enhancement, textcat, front-end, solved\
**Created:** [October 31, 2019, 3:18pm UTC](https://support.prodi.gy/t/spans-not-displayed-in-classification-view/2168 "2019-10-31T15:18:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanP](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@JanP](https://support.prodi.gy/u/JanP)\
**Post date:** [October 31, 2019, 3:18pm UTC](https://support.prodi.gy/t/spans-not-displayed-in-classification-view/2168/1 "2019-10-31T15:18:17Z")

</div>

Hey!

Following Matthew's suggestion:

> [@text classification - is prodigy a good fit for the project?](https://support.prodi.gy/t/text-classification-is-prodigy-a-good-fit-for-the-project/2127/2):
>
> If you need to have certain keywords highlighted, you can add a `spans` object to your stream examples, so you won't have to use HTML. You can use an HTML view, but it makes things a lot harder, because you'll have to map to and from the text in your recipe in order to update the model (since the models all expect text, not html).

I have been trying to highlight certain spans in the classification view, using the textcat.teach recpipe.  
Unfortunately, I wasn't even able to reproduce the example from the docs listed under classification:

```python
{
    "text": "Apple updates its analytics service with new metrics",
    "spans": [
        {
            "start": 0,
            "end": 5,
            "label": "ORG"
        }
    ]
}

```

When running textcat.teach on a jsonl data, the spans are being ignored. I have read the docs cover to cover but didn't find any additional clues. What am I missing?

Thank you beforehand!

J.

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [October 31, 2019, 6:30pm UTC](https://support.prodi.gy/t/spans-not-displayed-in-classification-view/2168/2 "2019-10-31T18:30:46Z")

</div>

> [@JanP](#):
>
> When running textcat.teach on a jsonl data, the spans are being ignored. I have read the docs cover to cover but didn't find any additional clues. What am I missing?

I think the problem here is that the `textcat.teach` recipe and annotation model will reset the `"spans"`, because it also uses them internally if you're running the long-text classification mode (to highlight the sentences you're classifying). So allowing pre-set spans here could cause conflicts. So the `classification` interface itself supports rendering spans, but the recipe has claimed them.

One simple workaround could be to store the spans as `"_spans"` and then overwrite them after you run the model, sorter etc. on the stream. Like this:

```python
def overwrite_spans(stream):
    for eg in stream:
        eg["spans"] = eg["_spans"]
        yield eg

# at the very end of the recipe
stream = overwrite_spans(stream)

```

---

<div class="post-metadata">

**Author:** ![JanP](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@JanP](https://support.prodi.gy/u/JanP)\
**Post date:** [October 31, 2019, 7:25pm UTC](https://support.prodi.gy/t/spans-not-displayed-in-classification-view/2168/3 "2019-10-31T19:25:58Z")

</div>

Hi Ines!

Thank you for the fast response!  
This has indeed worked just fine.
