2

For example, I have user utterance of courses that look like this:

  CS101
  PHY101
  CHE101

How do I get 2 entities from this like: Course Name, Course Number?

So in my example:

Utterance:  CS101
Entities:
  Course Name:  CS
  Course Number: 101
Bill Software Engineer
  • 7,362
  • 23
  • 91
  • 174
  • 1
    Could you add a sample of the user's utterance? – Javier Capello Sep 24 '18 at 02:17
  • It's exactly what I have wrote: CS101, PHY101, etc – Bill Software Engineer Sep 24 '18 at 18:09
  • 2
    I've been looking into this and I couldn't get it to work, I think your best bet would be to create a `Regex Entity` using this regex `[a-z]{2,}[0-9]{3,}`. This will match any part of the utterance that has at least 2 words followed by at least 3 numbers. And in your bot code you can do: `var courseName = entity.Where(char.IsLetter); var courseNumber = entity.Where(char.IsNumber);` – Javier Capello Sep 24 '18 at 23:58
  • That's unfortunate. Thank you for looking into it though. – Bill Software Engineer Sep 25 '18 at 01:47
  • @Bill I just spoke to one of the LUIS devs directly, and confirmed that Javier Capello is correct. With LUIS we have how it tokenizes words from utterances built in and users cannot customize the tokenization, which is what you would've needed for your courses like CS101, etc. There's no way for LUIS to detect CS separately from 101 with how it tokenizes & only sees it as 1 token. You can use RegEx in your bot code as Javier suggested to parse appropriately – Zeryth Sep 27 '18 at 23:42
  • Hi Zeryth, thank you so much for this information! I will make a workaround. – Bill Software Engineer Sep 27 '18 at 23:47

1 Answers1

0

Unfortunately as @Zeryth and @Javier mentioned in the comments, Luis currently does not support this. Here is the work around I used based on the comments:

        let regex = /([A-Za-z]+)[^a-zA-Z\d:]?(\d{1,3})/g
        var match = regex.exec(matchString);
        if(match){
            ClassName = new Entity({type:"ClassName",entity:match[1],score:1});
            ClassNumber = new Entity({type:"ClassNumber",entity:match[2],score:1});
        }
Bill Software Engineer
  • 7,362
  • 23
  • 91
  • 174