UNPKG

@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

40 lines 1.38 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KeywordsTool = exports.StemmedKeyword = void 0; const tslib_1 = require("tslib"); const nlp_1 = require("../nlp"); class StemmedKeyword { constructor(rawKeyword, stemmedKeyword) { this.rawKeyword = rawKeyword; this.stemmedKeyword = stemmedKeyword; } toString() { return `${this.rawKeyword}: ${this.stemmedKeyword.toString()}`; } } exports.StemmedKeyword = StemmedKeyword; /** * Reports all the contents's stemmed keywords. * Useful to check if they're too short. */ class KeywordsTool { constructor(cms, locale, normalizer) { this.cms = cms; this.locale = locale; this.normalizer = normalizer; } dumpKeywords() { return tslib_1.__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 => nlp_1.Keyword.fromUtterance(kw, context.locale, this.normalizer)); keywords.set(res.common.name, stemmed); } return keywords; }); } } exports.KeywordsTool = KeywordsTool; //# sourceMappingURL=keyword-tools.js.map