# Email classification

**URL:** <https://forum.rasa.com/t/email-classification/35917>\
**Category:** Rasa Open Source\
**Created:** [October 15, 2020, 9:37am UTC](https://forum.rasa.com/t/email-classification/35917 "2020-10-15T09:37:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hajer](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Hajer](https://forum.rasa.com/u/Hajer)\
**Post date:** [October 15, 2020, 9:37am UTC](https://forum.rasa.com/t/email-classification/35917/1 "2020-10-15T09:37:12Z")

</div>

Hi ,I am using RASA NLU in my work recently. My subject is to classifiy email on two intents and a lots of entities like name of person, account number, membership number, phone number. I have tried a lot of configuration of pipeline but i couldn’t find the pipeline who succeed to extract these entities… In one email, there is a lot of entities to extract but the result is not concluant…

Is there anyone who do the same subject and can give me some tips? Is There an order who is using by NLU to exctract entities because sometimes when i move a word before an other the NLU recognise it and sometimes not…

Thank you for helping me

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [October 20, 2020, 7:42am UTC](https://forum.rasa.com/t/email-classification/35917/2 "2020-10-20T07:42:05Z")

</div>

What kind of pipeline are you currently using? Also can you maybe share some examples of your training data? That would make it easier to understand what kind of entities you are trying to extract. Also what language are you using?

In general we made quite good experience with the `DIETClassifier`. Often is already sufficient if you have a pipeline similar to

```auto
- name: WhitespaceTokenizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
  analyzer: char_wb
  min_ngram: 1
  max_ngram: 4
- name: DIETClassifier
  epochs: 100
- name: EntitySynonymMapper

```

---

<div class="post-metadata">

**Author:** ![Hajer](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Hajer](https://forum.rasa.com/u/Hajer)\
**Post date:** [October 20, 2020, 8:46am UTC](https://forum.rasa.com/t/email-classification/35917/3 "2020-10-20T08:46:19Z")

</div>

Hello, i am using french language with this pipepline 🙂

language: “fr” pipeline:

- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: “CRFEntityExtractor”
- name: LexicalSyntacticFeaturizer
- name: EntitySynonymMapper
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer analyzer: “char\_wb” min\_ngram: 1 max\_ngram: 4
- name: DIETClassifier epochs: 100 batch\_size: 64 entity\_recognition: False

I want to recognize Name of person, unmber account, membership number … but sometimes the NLU recognize some of these and sometimes no. It’s very random result… I have implemented some regex.

Thank you

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [October 20, 2020, 9:15am UTC](https://forum.rasa.com/t/email-classification/35917/4 "2020-10-20T09:15:34Z")

</div>

Can you show some of the mistakes your model makes?

---

<div class="post-metadata">

**Author:** ![Hajer](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Hajer](https://forum.rasa.com/u/Hajer)\
**Post date:** [October 20, 2020, 12:40pm UTC](https://forum.rasa.com/t/email-classification/35917/5 "2020-10-20T12:40:11Z")

</div>

For example : ##################################################################### Test n° 1 en 650 ms pour “Bonjour, je suis Madame Ludivine, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12”:

Intentions trouvées :

- modif\_RIB _(confiance : 0.9982733726501465)_
- autre _(confiance : 0.0017266019713133574)_

Entités trouvées :

- civilite : _“madame”_\*\*

> [@Hajer](#):
>
> For example : Test n° 1 en 650 ms pour “Bonjour, je suis Madame Ludivine, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12”:
> 
> Intentions trouvées :
> 
> - modif\_RIB _(confiance : 0.9982733726501465)_
> - autre _(confiance : 0.0017266019713133574)_
> 
> Entités trouvées :
> 
> - civilite : _“madame”_
> - numero\_adherent : _“1\1256325”_
> 
> Test n° 2 en 1111 ms pour “Bonjour, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12 Madame Ludivine”:
> 
> Intentions trouvées :
> 
> - modif\_RIB _(confiance : 0.9998962879180908)_
> - autre _(confiance : 1.0371021926403046E-4)_
> 
> Entités trouvées :
> 
> - numero\_adherent : _“1\1256325”_
> - civilite : _“Madame Ludivine”_
> 
> Civilite is Madame or Monsieur But the NLU don’t reconize the name of Ludivine and the phone number and sometimes he recognize one of them and sometimes no. Perhaps the orders matters ? I don’t know if you can give me some tips to enhance the entity extraction, it will be great

> [@Hajer](#):
>
> For example : Test n° 1 en 650 ms pour “Bonjour, je suis Madame Ludivine, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12”:
> 
> Intentions trouvées :
> 
> - modif\_RIB _(confiance : 0.9982733726501465)_
> - autre _(confiance : 0.0017266019713133574)_
> 
> Entités trouvées :
> 
> - civilite : _“madame”_
> - numero\_adherent : _“1\1256325”_
> 
> Test n° 2 en 1111 ms pour “Bonjour, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12 Madame Ludivine”:
> 
> Intentions trouvées :
> 
> - modif\_RIB _(confiance : 0.9998962879180908)_
> - autre _(confiance : 1.0371021926403046E-4)_
> 
> Entités trouvées :
> 
> - numero\_adherent : _“1\1256325”_
> - civilite : _“Madame Ludivine”_
> 
> Civilite is Madame or Monsieur But the NLU don’t reconize the name of Ludivine and the phone number and sometimes he recognize one of them and sometimes no. Perhaps the orders matters ? I don’t know if you can give me some tips to enhance the entity extraction, it will be great

- numero\_adherent : _“1\1256325”_\*\*

Test n° 2 en 1111 ms pour “Bonjour, numéro d’adhérent : 1\1256325, je vous met ci-joint mon rib vous pouvez-joindre au : 06 32 14 89 12 Madame Ludivine”:

Intentions trouvées :

- modif\_RIB _(confiance : 0.9998962879180908)_
- autre _(confiance : 1.0371021926403046E-4)_

Entités trouvées :

- numero\_adherent : _“1\1256325”_
- civilite : _“Madame Ludivine”_

An other examples: Test n° 9 en 1021 ms pour “Nouvel identité bancaire, numéro : 1/125468954”:

Intentions trouvées :

- modif\_RIB _(confiance : 1)_
- autre _(confiance : 1.0737703044425007E-12)_

Entités trouvées :

- numero\_adherent : _“1/125468954”_

Test n° 10 en 694 ms pour " numéro : 1/125468954 Nouvel identité bancaire":

Intentions trouvées :

- modif\_RIB _(confiance : 1)_
- autre _(confiance : 9.96091447172387E-13)_

Entités trouvées :

#################################################### Civilite is Madame or Monsieur But the NLU don’t reconize the name of Ludivine and the phone number and sometimes he recognize one of them and sometimes no. Perhaps the orders matters ? I don’t know if you can give me some tips to enhance the entity extraction, it will be great.

---

<div class="post-metadata">

**Author:** ![Hajer](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Hajer](https://forum.rasa.com/u/Hajer)\
**Post date:** [October 20, 2020, 12:46pm UTC](https://forum.rasa.com/t/email-classification/35917/6 "2020-10-20T12:46:11Z")

</div>

It’s a very simple example, but in a lot of case, the e-mail is much longer than this one

---

<div class="post-metadata">

**Author:** ![Tanja](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/tanja/32/4696_2.png) [@Tanja](https://forum.rasa.com/u/Tanja)\
**Post date:** [October 21, 2020, 12:28pm UTC](https://forum.rasa.com/t/email-classification/35917/7 "2020-10-21T12:28:10Z")

</div>

How much training data do you have? E.g. how much examples per entity? It often helps just to add a couple of more examples to the training data.

Also if you want to extract number of a certain pattern, I recommend to either use [duckling](https://rasa.com/docs/rasa/components#ducklinghttpextractor) or [RegexEntityExtractor](https://rasa.com/docs/rasa/components#regexentityextractor). That should help you to extract entities that follow a certain pattern.

Also it might be a good idea to switch to `DIETClassifier` for entity extraction instead of `CRFEntityExtractor` as it is usually a bit more powerful.

So maybe you can try the following config and use the `DIETClassifier` to extract `civilite` and the `RegexEntityExtractor` to extract the phone number, for example.

```auto
- name: WhitespaceTokenizer
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer
  analyzer: char_wb
  min_ngram: 1
  max_ngram: 4
- name: DIETClassifier
  epochs: 100
- name: RegexEntityExtractor
- name: EntitySynonymMapper

```

---

<div class="post-metadata">

**Author:** ![Hajer](https://avatars.discourse-cdn.com/v4/letter/h/f05b48/32.png) [@Hajer](https://forum.rasa.com/u/Hajer)\
**Post date:** [October 23, 2020, 11:24am UTC](https://forum.rasa.com/t/email-classification/35917/8 "2020-10-23T11:24:24Z")

</div>

Thank you, i am working on it. It 's already better. I am using this one now : language: “fr” pipeline:

- name: WhitespaceTokenizer
- name: RegexFeaturizer
- name: RegexEntityExtractor use\_regexes: True
- name: “CRFEntityExtractor”
- name: LexicalSyntacticFeaturizer
- name: CountVectorsFeaturizer
- name: CountVectorsFeaturizer analyzer: “char\_wb” min\_ngram: 1 max\_ngram: 4
- name: DIETClassifier epochs: 100
- name: EntitySynonymMapper

I have a question: the order of compoment like regexEntityExtractor before DietClassifier matter or not ? Is it better to put regexEntityExtractor after DietClassifer ?
