Alter utterance data before or during prediction

LUIS provides ways to manipulate the utterance before or during the prediction. These include fixing spelling, and fixing timezone issues for prebuilt datetimeV2.

Correct spelling errors in utterance

LUIS uses Bing Spell Check API V7 to correct spelling errors in the utterance. LUIS needs the key associated with that service. Create the key, then add the key as a querystring parameter at the endpoint.

You can also correct spelling errors in the Test panel by entering the key. The key is kept as a session variable in the browser for the Test panel. Add the key to the Test panel in each browser session you want spelling corrected.

Usage of the key in the test panel and at the endpoint count toward the key usage quota. LUIS implements Bing Spell Check limits for text length.

The endpoint requires two params for spelling corrections to work:

Param Value
spellCheck boolean
bing-spell-check-subscription-key Bing Spell Check API V7 endpoint key

When Bing Spell Check API V7 detects an error, the original utterance, and the corrected utterance are returned along with predictions from the endpoint.

  "query": "Book a flite to London?",
  "alteredQuery": "Book a flight to London?",
  "topScoringIntent": {
    "intent": "BookFlight",
    "score": 0.780123
  "entities": []

List of allowed words

The Bing spell check API used in LUIS does not support a list of words to ignore during the spell check alterations. If you need to allow a list of words or acronyms, process the utterance in the client application before sending the utterance to LUIS for intent prediction.

Change time zone of prebuilt datetimeV2 entity

When a LUIS app uses the prebuilt datetimeV2 entity, a datetime value can be returned in the prediction response. The timezone of the request is used to determine the correct datetime to return. If the request is coming from a bot or another centralized application before getting to LUIS, correct the timezone LUIS uses.

Endpoint querystring parameter

The timezone is corrected by adding the user's timezone to the endpoint using the timezoneOffset param. The value of timezoneOffset should be the positive or negative number, in minutes, to alter the time.

Param Value
timezoneOffset positive or negative number, in minutes

Daylight savings example

If you need the returned prebuilt datetimeV2 to adjust for daylight savings time, you should use the timezoneOffset querystring parameter with a +/- value in minutes for the endpoint query.

Add 60 minutes:

https://{region}{appId}?q=Turn the lights on?timezoneOffset=60&verbose={boolean}&spellCheck={boolean}&staging={boolean}&bing-spell-check-subscription-key={string}&log={boolean}

Remove 60 minutes:

https://{region}{appId}?q=Turn the lights on?timezoneOffset=-60&verbose={boolean}&spellCheck={boolean}&staging={boolean}&bing-spell-check-subscription-key={string}&log={boolean}

C# code determines correct value of timezoneOffset

The following C# code uses the TimeZoneInfo class's FindSystemTimeZoneById method to determine the correct timezoneOffset based on system time:

// Get CST zone id
TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");

// Get local machine's value of Now
DateTime utcDatetime = DateTime.UtcNow;

// Get Central Standard Time value of Now
DateTime cstDatetime = TimeZoneInfo.ConvertTimeFromUtc(utcDatetime, targetZone);

// Find timezoneOffset
int timezoneOffset = (int)((cstDatetime - utcDatetime).TotalMinutes);

Next steps