# Misaligned entity annotation for '01/03' in sentence (...)

**URL:** <https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538>\
**Category:** Rasa Open Source\
**Created:** [March 25, 2020, 11:59am UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538 "2020-03-25T11:59:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bayesianwannabe](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bayesianwannabe](https://forum.rasa.com/u/bayesianwannabe)\
**Post date:** [March 25, 2020, 11:59am UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/1 "2020-03-25T11:59:09Z")

</div>

What are my options if I have defined two entities (DD and MM) and need to capture the following values: DD: 01 MM: 03

My entity data is annotated as presented above, but seems that I need separate tokens for ‘01’ and ‘03’ while keeping their positions. What is the best modification I can adopt if I still want to use the language model from spacy?

For my current data, I am getting the following warning from `rasa train nlu`: “Misaligned entity annotation for ‘01/03’ in sentence ‘I made the purchase 01/03 and still didn’t receive it’”

---

<div class="post-metadata">

**Author:** ![lluchini](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lluchini/32/7609_2.png) [@lluchini](https://forum.rasa.com/u/lluchini)\
**Post date:** [March 25, 2020, 12:48pm UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/2 "2020-03-25T12:48:05Z")

</div>

Perhaps you have to escape the “/” character?

---

<div class="post-metadata">

**Author:** ![bayesianwannabe](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bayesianwannabe](https://forum.rasa.com/u/bayesianwannabe)\
**Post date:** [March 25, 2020, 1:07pm UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/3 "2020-03-25T13:07:52Z")

</div>

Hey Leonardo,

How would I do this in the Rasa pipeline? Should I include the escapes in the raw text as a previous layer?

I am also considering two alternatives:

- Creating a new spacy language model from the one I am using, copying it but adding some special cases/rules like a regex to make ‘01/03’ as three tokens: ‘01’, ‘/’ and ‘03’, then loading the new model in the beginning of the Rasa pipeline as something as:

- Creating a new NLU tokenizer component using WhiteSpaceTokenizer source code as a template adding the regex for the date pattern, but losing some of the ‘intelligence’ of the spacy component that makes an unique token from ‘U.K.’ due to the special rules.

I am more prone to the custom spacyNLP language model, but I am still doing a little research on how to do this. Any readings that you would recommend?

---

<div class="post-metadata">

**Author:** ![lluchini](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lluchini/32/7609_2.png) [@lluchini](https://forum.rasa.com/u/lluchini)\
**Post date:** [March 25, 2020, 1:24pm UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/4 "2020-03-25T13:24:09Z")

</div>

I don’t know if I’m thinking too simple here, but, I would neither.

I would simple put on nlu.md samples to teach the RASA recognize as two disticnt items/slots, like:

```
## intent:date
- Some text to intent [Day](day) /[Month](month)
```

---

<div class="post-metadata">

**Author:** ![bayesianwannabe](https://avatars.discourse-cdn.com/v4/letter/b/bc8723/32.png) [@bayesianwannabe](https://forum.rasa.com/u/bayesianwannabe)\
**Post date:** [March 25, 2020, 1:38pm UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/5 "2020-03-25T13:38:25Z")

</div>

Thank you for the reply.

As I am using an custom annotator for the intents/entities and due to the scale and connection to a database, I am using the json format for the nlu instances.

Do you think maybe the markdown format deals with this in a different way?

The sentence (notice that there are no whitespaces in the date on the raw text):

‘I made the purchase 01/03 and still didn’t receive it’

Is annotated as:

```
  {
    "text": "I made the purchase 01/03 and still didn’t receive it",
    "intent": "purchase_not_received",
    "entities": [
      {
        "raw": "01",
        "value": "01",
        "entity": "DD",
        "start": 20,
        "end": 22
      },
      {
        "raw": "03",
        "value": "03",
        "entity": "MM",
        "start": 23,
        "end": 25
      }
    ]
  }
```

---

<div class="post-metadata">

**Author:** ![lluchini](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lluchini/32/7609_2.png) [@lluchini](https://forum.rasa.com/u/lluchini)\
**Post date:** [March 25, 2020, 2:09pm UTC](https://forum.rasa.com/t/misaligned-entity-annotation-for-01-03-in-sentence/26538/6 "2020-03-25T14:09:52Z")

</div>

> [@bayesianwannabe](#):
>
> Do you think maybe the markdown format deals with this in a different way?

Perhaps, you’re ahead of me, I still using the stock options of RASA / RASA X, but can you create a simple demo bot and try give some sample to it using the default annotator and see if it work as expected?
