Search code examples
botframeworkazure-cognitive-servicesazure-language-understanding

How can I use Luis to better match city names?


I'm playing with the bot framework and the cognitive services from Microsoft by doing a chatbot for Slack.

  • A user asks for the weather in a city, Luis recognises the intent.
  • Then a call to a weather API is done with the city that Luis extracted.

It works pretty well for well-known cities. However, for some others, Luis won't match a specific city as a geographyV2 entity (the prebuilt entity I picked).

Because of that the request to the weather API will be failing since no city has been recognised by Luis.

Should I avoid geographyV2 for another entity or can I help Luis in the process?

Here are some classic examples of users inputs:

  • How is the weather in Paris?
  • What's the weather like in Bangkok
  • What is the weather in Olomouc (fails here to recognise Olomouc)
  • What's the weather in New York

Solution

  • Here are a few tips based on my experience with that kind of use-cases:

    • Prebuilt entities are often good accelerators but if you are in a "non-US" context, you often have problems with things not recognized like you said

    • As a consequence, create your own entity and train your LUIS App with a lot of samples and variations in terms of sentences (don't train it only with the same sentence and just another city name)

    You will still have missing values sometimes (or sometimes things that are not cities which are found), but it will be better because as you are in a bot:

    • if know no entity has been found, you can ask the user "Ok I see that you are looking for the weather, but could you precise where?" and then use directly the result

    • if you have a wrong city name, you can see it when you call your weather API and also tell your end-user that you did not understand the city properly