hexo-related-posts
Version:
Hexo plugin that generates related posts list with TF/IDF algorithm
10 lines (7 loc) • 451 B
JavaScript
const vectorCosCompare = require('./vectorCosCompare');
const generateWordCountVector = require('./../tfidf/generateWordCountVector');
const textCosCompare = (text1, text2, reservedWords, stemmers) =>
String(text1 || '').trim() && String(text2 || '').trim()
? vectorCosCompare(generateWordCountVector(text1, reservedWords, stemmers), generateWordCountVector(text2, reservedWords, stemmers))
: 0;
module.exports = textCosCompare;