How to use @microsoft/recognizers-text-sequence - 10 common examples

To help you get started, we’ve selected a few @microsoft/recognizers-text-sequence 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 BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / email.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';
        const results = recognizers.recognizeEmail(utterance, locale);
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / socialMedia.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        let results: any;
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';
        switch(this.promptType)
        {
            case SocialMediaPromptType.Mention:
                results = recognizers.recognizeMention(utterance, locale);
                break;
            case SocialMediaPromptType.Hashtag:
                results = recognizers.recognizeHashtag(utterance, locale);
                break;
        }
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / socialMedia.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        let results: any;
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';
        switch(this.promptType)
        {
            case SocialMediaPromptType.Mention:
                results = recognizers.recognizeMention(utterance, locale);
                break;
            case SocialMediaPromptType.Hashtag:
                results = recognizers.recognizeHashtag(utterance, locale);
                break;
        }
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / phone.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';
        const results = recognizers.recognizePhoneNumber(utterance, locale);
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / internet.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        let results: any;
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';

        switch(this.promptType)
        {
            case InternetProtocolPromptType.IPAddress:
                results = recognizers.recognizeIpAddress(utterance, locale);
                break;
            case InternetProtocolPromptType.URL:
                results = recognizers.recognizeURL(utterance, locale);
                break;
        }
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / guid.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';
        const results = recognizers.recognizeGUID(utterance, locale);
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-dialog-prompts / src / internet.ts View on Github external
protected async onRecognize(context: TurnContext, state: any, options: PromptOptions): Promise> {
        const result: PromptRecognizerResult = { succeeded: false };
        let results: any;
        const activity: Activity = context.activity;
        const utterance: string = activity.text;
        const locale: string = activity.locale || this.defaultLocale || 'en-us';

        switch(this.promptType)
        {
            case InternetProtocolPromptType.IPAddress:
                results = recognizers.recognizeIpAddress(utterance, locale);
                break;
            case InternetProtocolPromptType.URL:
                results = recognizers.recognizeURL(utterance, locale);
                break;
        }
        if (results.length > 0 && results[0].resolution != null) {
            try {
                result.succeeded = true;
                result.value = results[0].resolution.value;
            }
            catch(e) {
                console.log(e);
            }
        }
        return result;
    }
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-middleware-text-recognizer / src / email.ts View on Github external
public async onTurn(context: TurnContext, next: () => Promise): Promise {
        if (context.activity.type === ActivityTypes.Message) {
            const emails: ModelResult[] = recognizeEmail(context.activity.text, this.defaultLocale);
            const emailEntities: string[] = [];
            if (emails.length > 0) {
                for (const i of emails) {
                    emailEntities.push(i.resolution.value);
                }
                context.turnState.set('emailEntities', emailEntities);
            }
        }
        await next();
    }
}
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-middleware-text-recognizer / src / socialMedia.ts View on Github external
public async onTurn(context: TurnContext, next: () => Promise): Promise {
        if (context.activity.type === ActivityTypes.Message) {
            const mentions: ModelResult[] = recognizeMention(context.activity.text, this.defaultLocale);
            const hastags: ModelResult[] = recognizeHashtag(context.activity.text, this.defaultLocale);
            const mentionEntities: string[] = [];
            const hastagEntities: string[] = [];
            if (mentions.length > 0) {
                for (const i of mentions) {
                    mentionEntities.push(i.resolution.value);
                }
                context.turnState.set('mentionEntities', mentionEntities);
            }
            if (hastags.length > 0) {
                for (const i of hastags) {
                    hastagEntities.push(i.resolution.value);
                }
                context.turnState.set('hastagEntities', hastagEntities);
            }
        }
        await next();
github BotBuilderCommunity / botbuilder-community-js / libraries / botbuilder-middleware-text-recognizer / src / socialMedia.ts View on Github external
public async onTurn(context: TurnContext, next: () => Promise): Promise {
        if (context.activity.type === ActivityTypes.Message) {
            const mentions: ModelResult[] = recognizeMention(context.activity.text, this.defaultLocale);
            const hastags: ModelResult[] = recognizeHashtag(context.activity.text, this.defaultLocale);
            const mentionEntities: string[] = [];
            const hastagEntities: string[] = [];
            if (mentions.length > 0) {
                for (const i of mentions) {
                    mentionEntities.push(i.resolution.value);
                }
                context.turnState.set('mentionEntities', mentionEntities);
            }
            if (hastags.length > 0) {
                for (const i of hastags) {
                    hastagEntities.push(i.resolution.value);
                }
                context.turnState.set('hastagEntities', hastagEntities);
            }
        }