yoastseo
Version:
Yoast client-side content analysis
38 lines (36 loc) • 1.38 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createBasicWordForms = createBasicWordForms;
var _stemPrefixedFunctionWords = require("../../../helpers/morphology/stemPrefixedFunctionWords.js");
var _prefixedFunctionWords = require("../config/prefixedFunctionWords.js");
/**
* Creates basic word forms for a given Arabic word.
*
* @param {string} word The word for which to create basic word forms.
*
* @returns {Array} Prefixed and de-prefixed variations of a word.
*/
function createBasicWordForms(word) {
const forms = [];
/*
* Add prefixes to the input word. We always do this, since some words
* beginning with a prefix-like letter might be exceptions where this is the
* actual first letter of the word.
*/
forms.push(..._prefixedFunctionWords.PREFIXED_FUNCTION_WORDS.map(basicPrefix => basicPrefix + word));
const {
stem,
prefix
} = (0, _stemPrefixedFunctionWords.stemPrefixedFunctionWords)(word, _prefixedFunctionWords.PREFIXED_FUNCTION_WORDS_REGEX);
if (prefix !== "") {
/*
If a word starts with one of the prefixes, we strip it and attach all prefixes to the stem.
*/
forms.push(stem);
forms.push(..._prefixedFunctionWords.PREFIXED_FUNCTION_WORDS.map(basicPrefix => basicPrefix + stem));
}
return forms;
}
//# sourceMappingURL=createBasicWordForms.js.map