Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | const Ramekin = require('./ramekin') const util = require('./lib/util') const moment = require('moment') const fs = require('fs') const snapshotTestTimeOptions = { start: moment('2019-04-22T23:48:05+00:00').subtract(1, 'day').toDate(), end: moment('2019-04-22T23:48:05+00:00').toDate() } const r = new Ramekin() const articles = JSON.parse(fs.readFileSync(`${__dirname}/tests/test-articles.json`, 'utf8')) r.ingestAll(articles) const searchOptions = r.buildSearchCriteria(snapshotTestTimeOptions) // find all the common phrases used in respective subject, over the past day const usedPhrases = r.usedPhrases(searchOptions) console.log(`There are ${usedPhrases.length} used phrases and ${Object.keys(r.docs).length} docs`) // duplicated data used later for sorting let trendPhrases = r.trendUsedPhrases(usedPhrases, searchOptions) // remove sub phrases (i.e. "Tour de", compared to "Tour de France") trendPhrases = r.removeSubPhrases(trendPhrases) const docPhrases = r.constructor.getDocPhrasesFromTrends(trendPhrases) // rank results - @todo: needs making nicer trendPhrases.sort((a, b) => b.score === a.score ? b.phrase.length - a.phrase.length : b.score - a.score ) console.log(trendPhrases.slice(0, 10)) |