@enonic/js-utils
Version:
Enonic XP JavaScript Utils
233 lines (232 loc) • 5.05 kB
JavaScript
;
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = function(target, all) {
for(var name in all)__defProp(target, name, {
get: all[name],
enumerable: true
});
};
var __copyProps = function(to, from, except, desc) {
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
try {
var _loop = function() {
var key = _step.value;
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: function() {
return from[key];
},
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
};
for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally{
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally{
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
return to;
};
var __toCommonJS = function(mod) {
return __copyProps(__defProp({}, "__esModule", {
value: true
}), mod);
};
// string/unStem.ts
var unStem_exports = {};
__export(unStem_exports, {
unStem: function() {
return unStem;
}
});
module.exports = __toCommonJS(unStem_exports);
function unStemEnglish(word) {
return [
"arsen",
"commun",
"gener",
"'s'",
"'s",
"ied",
"s",
"ies",
"sses",
"ss",
"us",
"",
"bb",
"dd",
"ff",
"gg",
"bl",
"mm",
"nn",
"pp",
"rr",
"at",
"tt",
"iz",
"ed",
"eed",
"ing",
"edly",
"eedly",
"ingly",
"anci",
"enci",
"ogi",
"li",
"bli",
"abli",
"alli",
"fulli",
"lessli",
"ousli",
"entli",
"aliti",
"biliti",
"iviti",
"tional",
"ational",
"alism",
"ation",
"ization",
"izer",
"ator",
"iveness",
"fulness",
"ousness",
"icate",
"ative",
"alize",
"iciti",
"ical",
"tional",
"ational",
"ful",
"ness",
"ic",
"ance",
"ence",
"able",
"ible",
"ate",
"ive",
"ize",
"iti",
"al",
"ism",
"ion",
"er",
"ous",
"ant",
"ent",
"ment",
"ement",
"e",
"l",
"succeed",
"proceed",
"exceed",
"canning",
"inning",
"earring",
"herring",
"outing",
"andes",
"atlas",
"bias",
"cosmos",
"dying",
"early",
"gently",
"howe",
"idly",
"lying",
"news",
"only",
"singly",
"skies",
"skis",
"sky",
"tying",
"ugly"
].map(function(post) {
return "".concat(word).concat(post);
});
}
function unStemNorwegian(word) {
return [
"a",
"e",
"ede",
"ande",
"ende",
"ane",
"ene",
"hetene",
"erte",
"en",
"heten",
"ar",
"er",
"heter",
"s",
"as",
"es",
"edes",
"endes",
"enes",
"hetenes",
"ens",
"hetens",
"ers",
"ets",
"et",
"het",
"ert",
"ast",
"dt",
"vt",
"leg",
"eleg",
"ig",
"eig",
"lig",
"elig",
"els",
"lov",
"elov",
"slov",
"hetslov"
].map(function(post) {
return "".concat(word).concat(post);
});
}
function unStem(word, language) {
switch(language){
case "en":
return unStemEnglish(word);
case "no":
return unStemNorwegian(word);
default:
throw new Error("Unsupported lanugage:".concat(language));
}
}