UNPKG

yoastseo

Version:

Yoast client-side content analysis

31 lines (28 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = notInclusiveWhenStandalone; var _isFollowedByException = require("./isFollowedByException"); var _isFollowedByParticiple = require("./isFollowedByParticiple"); var _functionWords = require("../../../../languageProcessing/languages/en/config/functionWords"); var _removePunctuation = require("../../../../languageProcessing/helpers/sanitize/removePunctuation"); var _languageProcessing = require("../../../../languageProcessing"); // Filter tokens from the exception lists that cause trouble when passed to getWords. // Some punctuation marks are still removed in getWords, as they are not in our punctuation list. // Those are filtered here out to prevent getWords returning an empty list. const filteredPunctuationList = _removePunctuation.punctuationList.filter(punctuationMark => (0, _languageProcessing.getWords)(punctuationMark, "\\s", false).length > 0); /** * Returns a callback that checks whether a non-inclusive word is standalone: * "The undocumented are there". is not inclusive, "The undocumented" is standalone. * "The undocumented people are there." is inclusive, in "The undocumented people", "the undocumented" is not standalone. * @param {string[]} words A list of words that is being queried. * @param {string[]} nonInclusivePhrase A list of words that are the non-inclusive phrase. * @returns {function} A callback that checks whether a non-inclusive term is standalone. */ function notInclusiveWhenStandalone(words, nonInclusivePhrase) { return index => { return (0, _isFollowedByException.isFollowedByException)(words, nonInclusivePhrase, _functionWords.nonNouns)(index) || (0, _isFollowedByParticiple.isFollowedByParticiple)(words, nonInclusivePhrase)(index) || (0, _isFollowedByException.isFollowedByException)(words, nonInclusivePhrase, filteredPunctuationList)(index); }; } //# sourceMappingURL=notInclusiveWhenStandalone.js.map