UNPKG

yoastseo

Version:

Yoast client-side content analysis

33 lines (32 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = getParticiples; var _lodash = require("lodash"); var _yoastseo = require("yoastseo"); var _passiveVoiceIrregulars = _interopRequireDefault(require("../../config/internal/passiveVoiceIrregulars")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const { matchRegularParticiples, getWords } = _yoastseo.languageProcessing; /** * Creates participle array for the participles found in a clause. * * @param {string} clauseText The clause to find participles in * * @returns {Array} The list with participles. */ function getParticiples(clauseText) { const words = getWords(clauseText); const foundParticiples = []; (0, _lodash.forEach)(words, function (word) { const regex = [/\w+ed($|[ \n\r\t.,'()"+\-;!?:/»«‹›<>])/ig]; if (matchRegularParticiples(word, regex).length !== 0 || (0, _lodash.includes)(_passiveVoiceIrregulars.default, word)) { foundParticiples.push(word); } }); return foundParticiples; } //# sourceMappingURL=getParticiples.js.map