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

32 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SearchRegression = exports.GroundTruth = void 0; const tslib_1 = require("tslib"); class GroundTruth { constructor(utterance, contentId) { this.utterance = utterance; this.contentId = contentId; } } exports.GroundTruth = GroundTruth; class SearchRegression { constructor(plugin, evaluator) { this.plugin = plugin; this.evaluator = evaluator; } run(matchType, groundTruths, locale) { return tslib_1.__awaiter(this, void 0, void 0, function* () { let sumEvals = 0; let count = 0; for (const gt of groundTruths) { count++; const res = yield this.plugin.search.searchByKeywords(gt.utterance, matchType, { locale }); const pos = res.findIndex(res => res.contentId.id == gt.contentId); sumEvals += this.evaluator(pos >= 0 ? pos : undefined, res.length); } return sumEvals / count; }); } } exports.SearchRegression = SearchRegression; //# sourceMappingURL=regression-tools.js.map