#VS2017 – Using Microsoft.Recognizers to recognize and solve numbers, units and date / time; in multiple languages

Hi!

During the session of the Global Azure Bootcamp, one of the topics that I shared was related to Language Understanding. We live in days where is very easy to add natural language capabilities to our applications. In general, the first thing we usually think about is to use LUIS for this, however, there are situations where we can save an HTTP call and carry out the analysis “in local mode”. Welcome to Microsoft.Recognizers

Since it is best to let the code explain itself, here is a portion of the code directly from the Github repository that explains some of the scenarios covered to recognize numbers,
units of measurement, dates, etc. (see references)

 

using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.DateTime;
using Microsoft.Recognizers.Text.Number;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Microsoft.Recognizers.Text.Sequence;
// Use English for the Recognizers culture
var culture = Culture.English;
// Number recognizer will find any number from the input
// E.g "I have two apples" will return "2".
NumberRecognizer.RecognizeNumber(query, culture);
// Ordinal number recognizer will find any ordinal number
// E.g "eleventh" will return "11".
NumberRecognizer.RecognizeOrdinal(query, culture);
// Percentage recognizer will find any number presented as percentage
// E.g "one hundred percents" will return "100%"
NumberRecognizer.RecognizePercentage(query, culture);
// Number Range recognizer will find any cardinal or ordinal number range
// E.g. "between 2 and 5" will return "(2,5)"
NumberRecognizer.RecognizeNumberRange(query, culture);
// Age recognizer will find any age number presented
// E.g "After ninety five years of age, perspectives change" will return "95 Year"
NumberWithUnitRecognizer.RecognizeAge(query, culture);
// Currency recognizer will find any currency presented
// E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar"
NumberWithUnitRecognizer.RecognizeCurrency(query, culture);
// Dimension recognizer will find any dimension presented
// E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile"
NumberWithUnitRecognizer.RecognizeDimension(query, culture);
// Temperature recognizer will find any temperature presented
// E.g "Set the temperature to 30 degrees celsius" will return "30 C"
NumberWithUnitRecognizer.RecognizeTemperature(query, culture);
// Datetime recognizer This model will find any Date even if its write in coloquial language
// E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00"
DateTimeRecognizer.RecognizeDateTime(query, culture);
// PhoneNumber recognizer will find any phone number presented
// E.g "My phone number is ( 19 ) 38294427."
SequenceRecognizer.RecognizePhoneNumber(query, culture);
//IP recognizer will find any Ipv4/Ipv6 presented
// E.g "My Ip is 8.8.8.8"
SequenceRecognizer.RecognizeIpAddress(query, culture);
//Boolean recognizer will find yes/no like responses, including emoji –
// E.g "yup, I need that" will return "True"
ChoiceRecognizer.RecognizeBoolean(query, culture);

view raw
MsRecognizers.cs
hosted with ❤ by GitHub

It is very interesting at the same time useful, and to date it supports the languages ​​Chinese, English, French, Spanish and Portuguese.

Greetings @ Toronto

El Bruno

References

#VS2017 – Utilizando Microsoft.Recognizers para reconocer y resolver números, unidades y fecha / hora; en múltiples idiomas

Buenas!

Durante la sesión del Global Azure Bootcamp, uno de los temas que comente fue que estamos en un momento donde es muy simple agregar capacidades de lenguaje natural a nuestras aplicaciones. Por lo general, lo primero que solemos pensar es utilizar LUIS para esto, sin embargo, existen situaciones donde podemos ahorrarnos una llamada HTTP y realizar el análisis “en local”. Para esto existe Microsoft.Recognizers

Como lo mejor es dejar que el código se explique por si mismo, he aquí una porción de código directamente desde el repositorio de Github que explica algunos de los escenarios cubiertos para reconocer números, unidades de medida, fechas, etc. (ver referencias)

using Microsoft.Recognizers.Text;
using Microsoft.Recognizers.Text.DateTime;
using Microsoft.Recognizers.Text.Number;
using Microsoft.Recognizers.Text.NumberWithUnit;
using Microsoft.Recognizers.Text.Sequence;
// Use English for the Recognizers culture
var culture = Culture.English;
// Number recognizer will find any number from the input
// E.g "I have two apples" will return "2".
NumberRecognizer.RecognizeNumber(query, culture);
// Ordinal number recognizer will find any ordinal number
// E.g "eleventh" will return "11".
NumberRecognizer.RecognizeOrdinal(query, culture);
// Percentage recognizer will find any number presented as percentage
// E.g "one hundred percents" will return "100%"
NumberRecognizer.RecognizePercentage(query, culture);
// Number Range recognizer will find any cardinal or ordinal number range
// E.g. "between 2 and 5" will return "(2,5)"
NumberRecognizer.RecognizeNumberRange(query, culture);
// Age recognizer will find any age number presented
// E.g "After ninety five years of age, perspectives change" will return "95 Year"
NumberWithUnitRecognizer.RecognizeAge(query, culture);
// Currency recognizer will find any currency presented
// E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar"
NumberWithUnitRecognizer.RecognizeCurrency(query, culture);
// Dimension recognizer will find any dimension presented
// E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile"
NumberWithUnitRecognizer.RecognizeDimension(query, culture);
// Temperature recognizer will find any temperature presented
// E.g "Set the temperature to 30 degrees celsius" will return "30 C"
NumberWithUnitRecognizer.RecognizeTemperature(query, culture);
// Datetime recognizer This model will find any Date even if its write in coloquial language
// E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00"
DateTimeRecognizer.RecognizeDateTime(query, culture);
// PhoneNumber recognizer will find any phone number presented
// E.g "My phone number is ( 19 ) 38294427."
SequenceRecognizer.RecognizePhoneNumber(query, culture);
//IP recognizer will find any Ipv4/Ipv6 presented
// E.g "My Ip is 8.8.8.8"
SequenceRecognizer.RecognizeIpAddress(query, culture);
//Boolean recognizer will find yes/no like responses, including emoji –
// E.g "yup, I need that" will return "True"
ChoiceRecognizer.RecognizeBoolean(query, culture);

view raw
MsRecognizers.cs
hosted with ❤ by GitHub

Es muy interesante a la par que útil, y al día de la fecha soporta los lenguajes Chino, Inglés, Francés, Español y Portugués.

Saludos @ Toronto

El Bruno

References