How to use the @microsoft/recognizers-text-suite.Culture function in @microsoft/recognizers-text-suite

To help you get started, we’ve selected a few @microsoft/recognizers-text-suite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / BotBuilder-Samples / samples / javascript_nodejs / 44.prompt-for-user-input / bots / customPromptBot.js View on Github external
static validateAge(input) {
        // Try to recognize the input as a number. This works for responses such as "twelve" as well as "12".
        try {
            // Attempt to convert the Recognizer result to an integer. This works for "a dozen", "twelve", "12", and so on.
            // The recognizer returns a list of potential recognition results, if any.
            const results = Recognizers.recognizeNumber(input, Recognizers.Culture.English);
            let output;
            results.forEach(result => {
                // result.resolution is a dictionary, where the "value" entry contains the processed string.
                const value = result.resolution.value;
                if (value) {
                    const age = parseInt(value);
                    if (!isNaN(age) && age >= 18 && age <= 120) {
                        output = { success: true, age: age };
                        return;
                    }
                }
            });
            return output || { success: false, message: 'Please enter an age between 18 and 120.' };
        } catch (error) {
            return {
                success: false,
github microsoft / Recognizers-Text / JavaScript / samples / simple-console / index.js View on Github external
var Recognizers = require('@microsoft/recognizers-text-suite');

// Use English for the Recognizers culture
const defaultCulture = Recognizers.Culture.English;

// Start Sample
showIntro();
runRecognition();

// Read from Console and recognize
function runRecognition() {
    var stdin = process.openStdin();

    // Read the text to recognize
    write('Enter the text to recognize: ');

    stdin.addListener('data', function (e) {
        var input = e.toString().trim();
        if (input) {
            // Exit
github microsoft / Recognizers-Text / JavaScript / samples / botbuilder / index.js View on Github external
var recognizeNumber = (query) => Recognizers.recognizeNumber(query, Recognizers.Culture.English);
var recognizeDate = (query) => Recognizers.recognizeDateTime(query, Recognizers.Culture.English);
github microsoft / Recognizers-Text / JavaScript / samples / botbuilder / index.js View on Github external
var recognizeDate = (query) => Recognizers.recognizeDateTime(query, Recognizers.Culture.English);
var recognizeBoolean = (query) => Recognizers.recognizeBoolean(query, Recognizers.Culture.English);