@botonic/plugin-contentful
Version:
Botonic Plugin Contentful is one of the **[available](https://github.com/hubtype/botonic/tree/master/packages)** plugins for Botonic. **[Contentful](http://www.contentful.com)** is a CMS (Content Management System) which manages contents of a great variet
36 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StemmerBg = void 0;
const stopwords_bg_1 = require("../stopwords/stopwords-bg");
const transformations_bg_1 = require("./transformations/transformations-bg");
class StemmerBg {
stem(tokens) {
return tokens.map(token => this.stemToken(token));
}
stemToken(token) {
if (this.isStopWord(token)) {
return token;
}
else {
return this.getRoot(token);
}
}
isStopWord(token) {
return stopwords_bg_1.bgDefaultStopWords.indexOf(token) != -1;
}
getRoot(token) {
const length = token.length;
if (length > 1) {
for (let i = 0; i < length; i++) {
const suffix = token.substring(i);
const root = transformations_bg_1.bgTransformations[suffix];
if (root != undefined) {
return token.substring(0, i).concat(root);
}
}
}
return token;
}
}
exports.StemmerBg = StemmerBg;
//# sourceMappingURL=stemmer-bg.js.map