UNPKG

yoastseo

Version:

Yoast client-side content analysis

41 lines (39 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isPassiveSentence; var _passiveVerbsWithLongVowel = _interopRequireDefault(require("../config/internal/passiveVerbsWithLongVowel")); var _yoastseo = require("yoastseo"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const { getWords } = _yoastseo.languageProcessing; /** * Checks the passed sentence to see if it contains Arabic passive verb-forms. * * @param {string} sentence The sentence to match against. * * @returns {Boolean} Whether the sentence contains Arabic passive voice. */ function isPassiveSentence(sentence) { const arabicPrepositionalPrefix = "و"; const words = getWords(sentence); const passiveVerbs = []; for (let word of words) { // Check if the word starts with prefix و if (word.startsWith(arabicPrepositionalPrefix)) { word = word.slice(1); } let wordWithDamma = -1; // Check if the first character has a damma or if the word is in the list of Arabic passive verbs if (word.length >= 2) { wordWithDamma = word[1].search("\u064F"); } if (wordWithDamma !== -1 || _passiveVerbsWithLongVowel.default.includes(word)) { passiveVerbs.push(word); } } return passiveVerbs.length !== 0; } //# sourceMappingURL=isPassiveSentence.js.map