UNPKG

retrieval

Version:

Full text search engine in js. Features BM25 ranking function that can be tuned.

16 lines (15 loc) 522 B
/* * Maps a query string input to the vector space spanned by the words of the * collection of documents we're searching on. */ const _ = require('lodash'); const makeZeros = require('../util/make_zeros.js'); const locateKeywords = require('./lib/locate_keywords.js'); const setEntries = require('../util/set_entries.js'); module.exports = function(query_, termIndex_) { zeroVec = makeZeros(_.size(termIndex_)); wordLocs = locateKeywords(query_, termIndex_); return setEntries(zeroVec, wordLocs ); };