1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 16:30:11 +00:00

Improve accuracy of keyword counts.

This commit is contained in:
hacksalot 2016-01-03 07:36:05 -05:00
parent 247eec396c
commit 0b7ef16a41

View File

@ -40,14 +40,15 @@ Keyword analysis for HackMyResume.
// http://stackoverflow.com/a/2593661/4942583 // http://stackoverflow.com/a/2593661/4942583
function regex_quote(str) { function regex_quote(str) {
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, "\\$&"); return (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, "\\$&");
}; }
var searchable = ''; var searchable = '';
rez.transformStrings( [], function trxString( key, val ) { rez.transformStrings( ['imp', 'computed', 'safe'], function trxString( key, val ) {
searchable += val; searchable += ' ' + val;
}); });
return rez.keywords().map(function(kw) { return rez.keywords().map(function(kw) {
var regex = new RegExp( '\\b' + regex_quote( kw )/* + '\\b'*/, 'ig');
var regex = new RegExp( regex_quote( kw ), 'ig'); var regex = new RegExp( regex_quote( kw ), 'ig');
var myArray, count = 0; var myArray, count = 0;
while ((myArray = regex.exec( searchable )) !== null) { while ((myArray = regex.exec( searchable )) !== null) {