Search code examples
regexandroid-intententityazure-language-understanding

Training LUIS pattern to handle singular and plural form of words


How can we train the Luis patterns to capture both plural and singular words?

Tried adding patterns like below

    I am looking for {coursename} course[s]

But it is not working.

Consider:

    Intent:**Training**
    Trained pattern:I am looking for {coursename} course

If the query is: "I am looking for python courses"

I want Luis to capture it as "Training" intent. It is not happening because the "Courses" is in the plural form from query and training for intent is done on a singular form(course)

I need a suggestion to manipulate the trained pattern to handle the plural form of words.

Thank you


Solution

  • I generally wouldn't recommend training by patterns for this exact reason. They are either too restrictive, or if you try to account for more variations, they can become too broad. Is there a reason you are not just training it by utterances? In other words, for your training intent you can and should have phrases like:

    • I am looking for python courses
    • I am looking for python course
    • I want to take a class on nodejs
    • Do you have any java classes?
    • I want to learn C#
    • Can you teach me javascript?

    Really the point of LUIS is that you can continue to add phrases over time so that it becomes better at recognizing user intent. It's not looking for exact matches either, so in this case something like I am looking for classes on ruby should be recognized even though that combination is never specified.

    It is unclear if you are using the pattern for entity detection as well, but again, you will fare better using other methods. If you only have a few values, a list entity works fine. If your list is large, varied, and/or may expand in the future, I would recommend using Machine Learned entities. Basically, you would create a machine learned entity then go back through your utterances and label these entities. Then LUIS can pick those up in the future based on not only the value but the context of how it is used in the sentence. If you don't plan to scale a list entity can be better since you won't get false positives (e.g. you won't recognize puppies as an entity if someone says "I want to learn about puppies").

    Most of this is basic functionality of LUIS, so if you browse the Microsoft documentation for LUIS (or Google it) you should find tons of additional information on how to use LUIS most effectively.