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

31 lines 1.14 kB
//TODO convert to a unit test // test('TEST: SimilarWordFinder performance', () => { import { CandidateWithKeywords, Keyword, MatchType, NormalizedUtterance, Word, } from '../nlp'; import { SimilarWordFinder } from '../nlp/similar-words'; class TestCandidate { } function candidate(kws, hasOnlyStopWords = false) { return new CandidateWithKeywords(new TestCandidate(), kws.map(k => kw(k, hasOnlyStopWords))); } function kw(kw, hasOnlyStopWords = false) { return new Keyword(`${kw}`, kw.split(' ').map(w => new Word(w, w)), hasOnlyStopWords); } function ut(text) { return new NormalizedUtterance(text, text.split(' ').map(w => new Word(w, w))); } function perform() { const sut = new SimilarWordFinder(true); for (let i = 0; i < 50; i++) { sut.addCandidate(candidate([`kw${i}`])); } let utterance = ''; for (let i = 0; i < 130; i++) { utterance += String(i) + ' '; } console.log(utterance.length); console.log(new Date()); sut.find(MatchType.KEYWORDS_AND_OTHERS_FOUND, ut(utterance), 1); console.log(new Date()); } perform(); //# sourceMappingURL=search-performance.js.map