@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
35 lines • 1.17 kB
JavaScript
import { __awaiter } from "tslib";
import { Keyword } from '../nlp';
export class StemmedKeyword {
constructor(rawKeyword, stemmedKeyword) {
this.rawKeyword = rawKeyword;
this.stemmedKeyword = stemmedKeyword;
}
toString() {
return `${this.rawKeyword}: ${this.stemmedKeyword.toString()}`;
}
}
/**
* Reports all the contents's stemmed keywords.
* Useful to check if they're too short.
*/
export class KeywordsTool {
constructor(cms, locale, normalizer) {
this.cms = cms;
this.locale = locale;
this.normalizer = normalizer;
}
dumpKeywords() {
return __awaiter(this, void 0, void 0, function* () {
const keywords = new Map();
const context = { locale: this.locale };
const results = yield this.cms.contentsWithKeywords(context);
for (const res of results) {
const stemmed = res.common.keywords.map(kw => Keyword.fromUtterance(kw, context.locale, this.normalizer));
keywords.set(res.common.name, stemmed);
}
return keywords;
});
}
}
//# sourceMappingURL=keyword-tools.js.map