How to use the @microsoft/recognizers-text.QueryProcessor.preProcess function in @microsoft/recognizers-text

To help you get started, we’ve selected a few @microsoft/recognizers-text 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 / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / models.ts View on Github external
parse(query: string, referenceDate: Date = new Date()): ModelResult[] {

        query = QueryProcessor.preProcess(query);
        let parseDates = new Array();

        try {
            let extractResults = this.extractor.extract(query, referenceDate);
            for (let result of extractResults) {
                let parseResult = this.parser.parse(result, referenceDate);
                if (Array.isArray(parseResult.value)) {
                    parseDates.push(...parseResult.value);
                }
                else {
                    parseDates.push(parseResult);
                }
            }
        }
        catch (err) {
            // Nothing to do. Exceptions in parse should not break users of recognizers.
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-sequence / src / sequence / models.ts View on Github external
parse(query: string): ModelResult[] {
        let parseResults = new Array();
        query = QueryProcessor.preProcess(query);

        try {
            let extractResults = this.extractor.extract(query);
            parseResults = extractResults.map(r => this.parser.parse(r));
        }
        catch (err) {
            // Nothing to do. in result process should not affect other extracted entities.
            // No result.
        }
        finally {
            return parseResults
                .map(o => o as ParseResult)
                .map(o => ({
                    start: o.start,
                    end: o.start + o.length - 1,
                    resolution: {
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-number / src / number / models.ts View on Github external
parse(query: string): ModelResult[] {
        query = QueryProcessor.preProcess(query, true);
        let parseNums: ParseResult[];

        try {
            let extractResults = this.extractor.extract(query);
            parseNums = extractResults.map(r => this.parser.parse(r));
        }
        catch (err) {
            // Nothing to do. Exceptions in result process should not affect other extracted entities.
            // No result.
        }
        finally {
            return parseNums
                .map(o => o as ParseResult)
                .map(o => ({
                    start: o.start,
                    end: o.start + o.length - 1,
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-number-with-unit / src / numberWithUnit / models.ts View on Github external
parse(query: string): ModelResult[] {
        query = QueryProcessor.preProcess(query, true);

        let extractionResults = new Array();

        try {
            for (let kv of this.extractorParsersMap.entries()) {
                let extractor = kv[0];
                let parser = kv[1];
                let extractResults = extractor.extract(query);
                let parseResults: ParseResult[] = [];
                for (let i = 0; i < extractResults.length; i++) {
                    let r = parser.parse(extractResults[i]);
                    if (r.value !== null) {
                        if (r.value instanceof Array) {
                            for (let j = 0; j < r.value.length; j++) {
                                parseResults.push(r.value[j]);
                            }