Regex for intent classifier

Hello,
I want to use regex for improving my intent classifier.
As explained in the doc -
Regular expressions can be used to support the intent classification and entity extraction.

regex:zipcode

  • [0-9]{5}

regex:greet

  • hey[^\s]*

does it mean that intent greet will be triggerred by RASA NLU only when user text starts with “hey
I want to understand it .
kindly help me understand how it works.
For your information , i know how regex can be helpful for entity extraction.


I used it as - \

intent:ask_assign

  • assign issue
  • assign issue to
  • assign issues
  • assign me

regex:ask_assign

  • assign[^\s]*

user_text_1 - assign issue
RASA - Received user message ‘assign issue’ with intent ‘{‘name’: ‘ask_assign’, ‘confidence’: 0.9508237838745117}’ and entities ‘[]’

user_text_2 - lets assign
RASA - Received user message ‘lets assign’ with intent ‘{‘name’: ‘ask_assign’, ‘confidence’: 0.8390434980392456}’ and entities ‘[]’

--------------------------------------------
my config.yml file is -\

Configuration for Rasa NLU.

Components

language: en

pipeline:

  • name: WhitespaceTokenizer

  • name: RegexFeaturizer

  • name: LexicalSyntacticFeaturizer

  • name: CRFEntityExtractor

  • name: CountVectorsFeaturizer

  • name: CountVectorsFeaturizer

    analyzer: “char_wb”

    min_ngram: 1

    max_ngram: 4

  • name: “EmbeddingIntentClassifier”

    epochs: 100

  • name: EntitySynonymMapper

Configuration for Rasa Core.

Policies

policies:

  • name: MemoizationPolicy

  • name: KerasPolicy

    max_history: 5

    epochs: 100

  • name: MappingPolicy

kindly help me
thanks

As introduced in rasa tutorial, I suppose the Regex only contributes to the feature of a sentence. One sentence may have numbers of features, and one regex is one of them. If the sentence has the regex, the feature is set to 1, otherwise 0. In the meantime, other features of the sentence are 1 or 0. In conclusion, Regex will influence the intent classfication but not decide it. In other words, results of intent classfication do not absolutely or entirely depend on matching the regex or not.

1 Like

@chong2 So we can’t just bind the text classification only with regex right ?

emmmm, I’m not so sure about that since I didn’t config the pipline with only regex and intent classifier. If the pipline with only regex and intent classifier works, I think it is what you mean “bind the text classification only with regex”. But even though it works, most intent classifiers would take token features (such as word itself, word before it and word after it, e.t.c) into acount.