How to use the @microsoft/recognizers-text-number.StringUtility.isNullOrWhitespace 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
return ret;
                    }
                }
            }

            // get minute
            let minStr = match.groups('min').value.toLowerCase();
            if (StringUtility.isNullOrWhitespace(minStr)) {
                minStr = match.groups('minnum').value;
                if (!StringUtility.isNullOrWhitespace(minStr)) {
                    min = this.config.numbers.get(minStr);
                    hasMin = true;
                }

                let tensStr = match.groups('tens').value;
                if (!StringUtility.isNullOrWhitespace(tensStr)) {
                    min += this.config.numbers.get(tensStr);
                    hasMin = true;
                }
            }
            else {
                min = Number.parseInt(minStr, 10);
                hasMin = true;
            }

            // get second
            let secStr = match.groups('sec').value.toLowerCase();
            if (!StringUtility.isNullOrWhitespace(secStr)) {
                second = Number.parseInt(secStr, 10);
                hasSec = true;
            }
        }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
}
            else {
                hour = Number.parseInt(hourStr, 10);
                if (!hour) {
                    hour = this.config.numbers.get(hourStr);
                    if (!hour) {
                        return ret;
                    }
                }
            }

            // get minute
            let minStr = match.groups('min').value.toLowerCase();
            if (StringUtility.isNullOrWhitespace(minStr)) {
                minStr = match.groups('minnum').value;
                if (!StringUtility.isNullOrWhitespace(minStr)) {
                    min = this.config.numbers.get(minStr);
                    hasMin = true;
                }

                let tensStr = match.groups('tens').value;
                if (!StringUtility.isNullOrWhitespace(tensStr)) {
                    min += this.config.numbers.get(tensStr);
                    hasMin = true;
                }
            }
            else {
                min = Number.parseInt(minStr, 10);
                hasMin = true;
            }

            // get second
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
}
            else if (!StringUtility.isNullOrWhitespace(match.groups('midafternoon').value)) {
                hour = 14;
                min = 0;
                second = 0;
            }
            else if (!StringUtility.isNullOrWhitespace(match.groups('midday').value)) {
                hour = 12;
                min = 0;
                second = 0;
            }
        }
        else {
            // get hour
            let hourStr = match.groups('hour').value;
            if (StringUtility.isNullOrWhitespace(hourStr)) {
                hourStr = match.groups('hournum').value.toLowerCase();
                hour = this.config.numbers.get(hourStr);
                if (!hour) {
                    return ret;
                }
            }
            else {
                hour = Number.parseInt(hourStr, 10);
                if (!hour) {
                    hour = this.config.numbers.get(hourStr);
                    if (!hour) {
                        return ret;
                    }
                }
            }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
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;
        }

        // adjust hour by suffix
        let timeSuffix = match.groups('suffix').value.toLowerCase();
        if (!StringUtility.isNullOrWhitespace(timeSuffix)) {
            let adjust = { hour: hour, min: min, hasMin: hasMin, hasAm: hasAm, hasPm: hasPm };
            this.config.adjustBySuffix(timeSuffix, adjust);
            hour = adjust.hour; min = adjust.min; hasMin = adjust.hasMin; hasAm = adjust.hasAm; hasPm = adjust.hasPm;
        }

        if (hour === 24) {
            hour = 0;
        }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
}

            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;
        }

        // adjust hour by suffix
        let timeSuffix = match.groups('suffix').value.toLowerCase();
        if (!StringUtility.isNullOrWhitespace(timeSuffix)) {
            let adjust = { hour: hour, min: min, hasMin: hasMin, hasAm: hasAm, hasPm: hasPm };
            this.config.adjustBySuffix(timeSuffix, adjust);
            hour = adjust.hour; min = adjust.min; hasMin = adjust.hasMin; hasAm = adjust.hasAm; hasPm = adjust.hasPm;
        }

        if (hour === 24) {
            hour = 0;
        }

        ret.timex = "T" + DateTimeFormatUtil.toString(hour, 2);
        if (hasMin) {
            ret.timex += ":" + DateTimeFormatUtil.toString(min, 2);
        }

        if (hasSec) {
            ret.timex += ":" + DateTimeFormatUtil.toString(second, 2);
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
}

                let tensStr = match.groups('tens').value;
                if (!StringUtility.isNullOrWhitespace(tensStr)) {
                    min += this.config.numbers.get(tensStr);
                    hasMin = true;
                }
            }
            else {
                min = Number.parseInt(minStr, 10);
                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) {
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
return ret;
                }
            }
            else {
                hour = Number.parseInt(hourStr, 10);
                if (!hour) {
                    hour = this.config.numbers.get(hourStr);
                    if (!hour) {
                        return ret;
                    }
                }
            }

            // get minute
            let minStr = match.groups('min').value.toLowerCase();
            if (StringUtility.isNullOrWhitespace(minStr)) {
                minStr = match.groups('minnum').value;
                if (!StringUtility.isNullOrWhitespace(minStr)) {
                    min = this.config.numbers.get(minStr);
                    hasMin = true;
                }

                let tensStr = match.groups('tens').value;
                if (!StringUtility.isNullOrWhitespace(tensStr)) {
                    min += this.config.numbers.get(tensStr);
                    hasMin = true;
                }
            }
            else {
                min = Number.parseInt(minStr, 10);
                hasMin = true;
            }
github microsoft / Recognizers-Text / JavaScript / packages / recognizers-date-time / src / dateTime / baseTime.ts View on Github external
// get minute
            let minStr = match.groups('minnum').value;
            let tensStr = match.groups('tens').value;

            if (!StringUtility.isNullOrWhitespace(minStr)) {
                min = this.config.numbers.get(minStr);
                if (tensStr) {
                    min += this.config.numbers.get(tensStr);
                }
                hasMin = true;
            }
        }
        else if (!StringUtility.isNullOrWhitespace(match.groups('mid').value)) {
            hasMid = true;
            if (!StringUtility.isNullOrWhitespace(match.groups('midnight').value)) {
                hour = 0;
                min = 0;
                second = 0;
            }
            else if (!StringUtility.isNullOrWhitespace(match.groups('midmorning').value)) {
                hour = 10;
                min = 0;
                second = 0;
            }
            else if (!StringUtility.isNullOrWhitespace(match.groups('midafternoon').value)) {
                hour = 14;
                min = 0;
                second = 0;
            }
            else if (!StringUtility.isNullOrWhitespace(match.groups('midday').value)) {
                hour = 12;

@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

81 / 100
Full package analysis