@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
32 lines • 953 B
JavaScript
import { bgDefaultStopWords } from '../stopwords/stopwords-bg';
import { bgTransformations } from './transformations/transformations-bg';
export 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 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 = bgTransformations[suffix];
if (root != undefined) {
return token.substring(0, i).concat(root);
}
}
}
return token;
}
}
//# sourceMappingURL=stemmer-bg.js.map