UNPKG

yoastseo

Version:

Yoast client-side content analysis

38 lines (35 loc) 1.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _SentenceTokenizer = _interopRequireDefault(require("../../../../helpers/sentence/SentenceTokenizer")); var _wordBoundaries = _interopRequireDefault(require("../../../../../config/wordBoundaries")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } // The beginning of a string (^) or one of the word boundaries from the wordBoundaries helper. const wordBoundariesForRegex = "(^|[" + (0, _wordBoundaries.default)().map(boundary => "\\" + boundary).join("") + "])"; const ordinalDotRegex = new RegExp(wordBoundariesForRegex + "\\d{1,3}\\.$"); /** * Class for tokenizing a (html) text into sentences. */ class GermanSentenceTokenizer extends _SentenceTokenizer.default { /** * Constructor * @constructor */ constructor() { super(); } /** * Checks whether a fullstop is an ordinal dot instead of a sentence splitter. * See: https://en.wikipedia.org/wiki/Ordinal_indicator#Ordinal_dot * * @param {string} currentSentence A string ending with a full stop. * @returns {boolean} Returns true if the full stop is an ordinal dot, false otherwise. */ endsWithOrdinalDot(currentSentence) { return ordinalDotRegex.test(currentSentence.trim()); } } exports.default = GermanSentenceTokenizer; //# sourceMappingURL=SentenceTokenizer.js.map