1.0.1 • Published 7 years ago
kwrank v1.0.1
kwrank
Dumb keyword-based (token-based) search rank lib.
Funcs.
Few formulas.
Strtok: takes string, return list of keywords/tokens. Optional takes separator (, by default). Splits by the separator, trims every entry, filter out empty strings and duplicates, sorts the array
Kwscore: takes two lists of tok, returns int
for each tok in first, if exists in sec then res++
Kwsort: takes a list of objects, and string (tok)
Clone the list, Filter out objects without "keywords" key, computes kwscore for each object (store it as key: score), sorts from highest to lowest kwscore, return sorted list.