hexo-related-posts
Version:
Hexo plugin that generates related posts list with TF/IDF algorithm
10 lines (7 loc) • 374 B
JavaScript
const removeNonAlphaChars = require('./removeNonAlphaChars');
const extractWords = (source, reservedWords, wordLength) =>
removeNonAlphaChars(source)
.split(' ')
.map((word) => word.trim())
.filter((word) => Object.keys(reservedWords).indexOf(word) !== -1 || (word.length >= wordLength && !/^\d+$/i.test(word)));
module.exports = extractWords;