# Unable to use regex feature

**URL:** <https://forum.rasa.com/t/unable-to-use-regex-feature/11976>\
**Category:** Rasa Open Source\
**Created:** [June 24, 2019, 2:48pm UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976 "2019-06-24T14:48:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubham](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shubham](https://forum.rasa.com/u/shubham)\
**Post date:** [June 24, 2019, 2:48pm UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/1 "2019-06-24T14:48:41Z")

</div>

I have 3 entities which contains numerical data

# intent:sales\_data

- 1213
- 1413
- 2213
- 3213
- 1213
- 10000413
- 30000413
- 75000413
- 500010000413
- 605010000413
- 633010000413

## regex:EV\_id

- ^\d{4}$

## regex:product\_id

- ^\d{8}$

## regex:Transaction\_id

- ^\d{12}$

my config file

pipeline:

- name: “SpacyNLP” model: “en\_core\_web\_lg”

- name: “SpacyTokenizer”

- name: “SpacyFeaturizer”

- name: “RegexFeaturizer”

- name: “CRFEntityExtractor” features: [[“low”, “title”, “upper”], [“bias”, “low”, “prefix5”, “prefix2”, “suffix5”, “suffix3”, “suffix2”, “upper”, “title”, “digit”, “pattern”], [“low”, “title”, “upper”] ]

- name: “EntitySynonymMapper”

- name: “CountVectorsFeaturizer”

- name: “EmbeddingIntentClassifier” intent\_tokenization\_flag: true intent\_split\_symbol: “+” epochs: 50

- name: DucklingHTTPExtractor url: [http://localhost:8000](http://localhost:8000) dimensions:

policies:

- name: MemoizationPolicy
- name: KerasPolicy
- name: MappingPolicy

but i am unable to use regex features even i enter 5 digit number it detects EV\_id help me with this issue .

@akelad@Juste @JulianGerhard

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [June 24, 2019, 5:04pm UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/2 "2019-06-24T17:04:28Z")

</div>

Hi @shubham

I built your bot based on your setup. This is my parsing-output for product:

```
POST http://localhost:5005/model/parse

{
	"text": "10000413"
}

{
    "intent": {
        "name": "sales_data",
        "confidence": 0.9558028579
    },
    "entities": [
        {
            "start": 0,
            "end": 8,
            "value": "10000413",
            "entity": "product_id",
            "confidence": 0.853251155,
            "extractor": "CRFEntityExtractor"
        }
    ],
    "intent_ranking": [
        {
            "name": "sales_data",
            "confidence": 0.9558028579
        },
        {
            "name": "goodbye",
            "confidence": 0.0675825328
        },
        {
            "name": "greet",
            "confidence": 0
        },
        {
            "name": "mood_great",
            "confidence": 0
        },
        {
            "name": "deny",
            "confidence": 0
        },
        {
            "name": "affirm",
            "confidence": 0
        }
    ],
    "text": "10000413"
} 

```

This is my parsing output for ev\_id:

```
POST http://localhost:5005/model/parse

{
	"text": "2213"
}

{
    "intent": {
        "name": "sales_data",
        "confidence": 0.9566286206
    },
    "entities": [
        {
            "start": 0,
            "end": 4,
            "value": "2213",
            "entity": "ev_id",
            "confidence": 0.8784737378,
            "extractor": "CRFEntityExtractor"
        }
    ],
    "intent_ranking": [
        {
            "name": "sales_data",
            "confidence": 0.9566286206
        },
        {
            "name": "goodbye",
            "confidence": 0.0442600176
        },
        {
            "name": "greet",
            "confidence": 0
        },
        {
            "name": "mood_great",
            "confidence": 0
        },
        {
            "name": "deny",
            "confidence": 0
        },
        {
            "name": "affirm",
            "confidence": 0
        }
    ],
    "text": "2213"
}

```

My modifications:

I simply used the CRFEntityExtractor without feature specifications and I used the following stories:

```
## product_id
* sales_data{"product_id": "56435678"}
 - utter_goodbye
 
## ev_id
* sales_data{"ev_id": "2481"}
 - utter_goodbye

```

Maybe you forgot to accept mentioned entities while triggering the intent? Another thing: the data you provided for those entities is a little bit poor regarding the fact, that e.g. ev\_id always ends on 13 (I don’t know if this is expected or not).

Regards

---

<div class="post-metadata">

**Author:** ![shubham](https://avatars.discourse-cdn.com/v4/letter/s/85e7bf/32.png) [@shubham](https://forum.rasa.com/u/shubham)\
**Post date:** [June 25, 2019, 4:30am UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/3 "2019-06-25T04:30:29Z")

</div>

> [@JulianGerhard](#):
>
> 10000413

even I am getting same result when I test it with 1234 (4 digit number ) or 54688458 (8 digit number ) but when i test it with 54215 (5 digit number ) I get Ev\_id as entity or 5451755 (9 digit number ) I get product\_id as entity

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [June 25, 2019, 6:03am UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/4 "2019-06-25T06:03:18Z")

</div>

Hi @shubham,

according to the documentation:

_Regex features don’t define entities nor intents! They simply provide patterns to help the classifier recognize entities and related intents. Hence, you still need to provide intent & entity examples as part of your training data!_

I think what you want to achieve is parsing either a ev\_id, product or transaction\_id by validating with a regex which of them it is. The RegEx Feature is only helping to predict the intent.

How about using one intent and the duckling extractor to extract the number and then validate it in a Custom- or FormAction to predict its use-case?

---

<div class="post-metadata">

**Author:** ![akelad](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/akelad/32/69_2.png) [@akelad](https://forum.rasa.com/u/akelad)\
**Post date:** [June 27, 2019, 3:14pm UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/5 "2019-06-27T15:14:16Z")

</div>

I would suggest using duckling to extract numbers instead and then fill your slots from custom actions, with some regex checking to decide which slot to fill

---

<div class="post-metadata">

**Author:** ![naoko](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/naoko/32/196_2.png) [@naoko](https://forum.rasa.com/u/naoko)\
**Post date:** [June 29, 2019, 10:52pm UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/6 "2019-06-29T22:52:20Z")

</div>

@shubham, I had a similar issue and wrote a custom component AKA True `RegexEntityExtractor`. Hope this helps! [RASA Regex Entity Extraction - Naoko - Medium](https://medium.com/@naoko.reeves/rasa-regex-entity-extraction-317f047b28b6)

---

<div class="post-metadata">

**Author:** ![JulianGerhard](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/juliangerhard/32/3781_2.png) [@JulianGerhard](https://forum.rasa.com/u/JulianGerhard)\
**Post date:** [July 2, 2019, 7:57am UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/7 "2019-07-02T07:57:04Z")

</div>

This looks pretty cool @naoko. I’ll give it a try today.

---

<div class="post-metadata">

**Author:** ![webdev-rohit](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/webdev-rohit/32/18943_2.png) [@webdev-rohit](https://forum.rasa.com/u/webdev-rohit)\
**Post date:** [May 11, 2022, 6:36am UTC](https://forum.rasa.com/t/unable-to-use-regex-feature/11976/8 "2022-05-11T06:36:48Z")

</div>

Hello @JulianGerhard did things work out for you?
