How to use the @microsoft/recognizers-text-number.StringUtility.isNullOrEmpty function in @microsoft/recognizers-text-number

To help you get started, we’ve selected a few @microsoft/recognizers-text-number 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 / baseTime.ts View on Github external
// adjust by desc string
        let descStr = match.groups('desc').value.toLowerCase();
        if (RegExpUtility.getMatches(this.config.utilityConfiguration.amDescRegex, descStr).length > 0
            || RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length > 0
            || !StringUtility.isNullOrEmpty(match.groups('iam').value)) {

            if (hour >= 12) {
                hour -= 12;
            }

            if (RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length === 0) {
                hasAm = true;
            }
        }
        else if (RegExpUtility.getMatches(this.config.utilityConfiguration.pmDescRegex, descStr).length > 0
            || !StringUtility.isNullOrEmpty(match.groups('ipm').value)) {

            if (hour < 12) {
                hour += 12;
            }

            hasPm = true;
        }

        // adjust min by prefix
        let timePrefix = match.groups('prefix').value.toLowerCase();
        if (!StringUtility.isNullOrWhitespace(timePrefix)) {
            let adjust = { hour: hour, min: min, hasMin: hasMin };
            this.config.adjustByPrefix(timePrefix, adjust);
            hour = adjust.hour; min = adjust.min; hasMin = adjust.hasMin;
        }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseMerged.ts View on Github external
private addPeriodToResolution(resolutions: StringMap, startType: string, endType: string, mod: string, result: StringMap) {
        let start = resolutions[startType];
        let end = resolutions[endType];
        if (!StringUtility.isNullOrEmpty(mod)) {
            // For the 'before' mod
            // 1. Cases like "Before December", the start of the period should be the end of the new period, not the start
            // 2. Cases like "More than 3 days before today", the date point should be the end of the new period
            if (mod === TimeTypeConstants.beforeMod) {
                if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end)) {
                    result[TimeTypeConstants.END] = start;
                }
                else {
                    result[TimeTypeConstants.END] = end;
                }
                return;
            }

            // For the 'after' mod
            // 1. Cases like "After January". the end of the period should be the start of the new period, not the end
            // 2. Cases like "More than 3 days after today", the date point should be the start of the new period
            if (mod === TimeTypeConstants.afterMod) {
                if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end)) {
                    result[TimeTypeConstants.START] = end;
                }
                else {
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseMerged.ts View on Github external
// 2. Cases like "More than 3 days before today", the date point should be the end of the new period
            if (mod === TimeTypeConstants.beforeMod) {
                if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end)) {
                    result[TimeTypeConstants.END] = start;
                }
                else {
                    result[TimeTypeConstants.END] = end;
                }
                return;
            }

            // For the 'after' mod
            // 1. Cases like "After January". the end of the period should be the start of the new period, not the end
            // 2. Cases like "More than 3 days after today", the date point should be the start of the new period
            if (mod === TimeTypeConstants.afterMod) {
                if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end)) {
                    result[TimeTypeConstants.START] = end;
                }
                else {
                    result[TimeTypeConstants.START] = start;
                }
                return;
            }
            if (mod === TimeTypeConstants.sinceMod) {
                result[TimeTypeConstants.START] = start;
                return;
            }
        }

        if (StringUtility.isNullOrEmpty(start) || StringUtility.isNullOrEmpty(end)) {
            return;
        }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
hasMin = true;
            }

            // get second
            let secStr = match.groups('sec').value.toLowerCase();
            if (!StringUtility.isNullOrWhitespace(secStr)) {
                second = Number.parseInt(secStr, 10);
                hasSec = true;
            }
        }

        // adjust by desc string
        let descStr = match.groups('desc').value.toLowerCase();
        if (RegExpUtility.getMatches(this.config.utilityConfiguration.amDescRegex, descStr).length > 0
            || RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length > 0
            || !StringUtility.isNullOrEmpty(match.groups('iam').value)) {

            if (hour >= 12) {
                hour -= 12;
            }

            if (RegExpUtility.getMatches(this.config.utilityConfiguration.amPmDescRegex, descStr).length === 0) {
                hasAm = true;
            }
        }
        else if (RegExpUtility.getMatches(this.config.utilityConfiguration.pmDescRegex, descStr).length > 0
            || !StringUtility.isNullOrEmpty(match.groups('ipm').value)) {

            if (hour < 12) {
                hour += 12;
            }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseMerged.ts View on Github external
protected addResolutionFields(dic: StringMap, key: string, value: string) {
        if (!StringUtility.isNullOrEmpty(value)) {
            dic[key] = value;
        }
    }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseMerged.ts View on Github external
if (mod === TimeTypeConstants.afterMod) {
                if (!StringUtility.isNullOrEmpty(start) && !StringUtility.isNullOrEmpty(end)) {
                    result[TimeTypeConstants.START] = end;
                }
                else {
                    result[TimeTypeConstants.START] = start;
                }
                return;
            }
            if (mod === TimeTypeConstants.sinceMod) {
                result[TimeTypeConstants.START] = start;
                return;
            }
        }

        if (StringUtility.isNullOrEmpty(start) || StringUtility.isNullOrEmpty(end)) {
            return;
        }

        result[TimeTypeConstants.START] = start;
        result[TimeTypeConstants.END] = end;
    }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseMerged.ts View on Github external
protected addResolutionFieldsAny(dic: Map, key: string, value: any) {
        if (value instanceof String) {
            if (!StringUtility.isNullOrEmpty(value as string)) {
                dic.set(key, value);
            }
        }
        else {
            dic.set(key, value);
        }
    }

@microsoft/recognizers-text-number

recognizers-text-number provides robust recognition and resolution of numbers expressed in multiple languages.

MIT
Latest version published 1 year ago

Package Health Score

79 / 100
Full package analysis