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


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"
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);

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


Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: