1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-10 15:57:07 +01:00

Add baseline keyword analysis.

This commit is contained in:
hacksalot
2016-01-03 06:39:46 -05:00
parent b3fb2c7130
commit 46c7fa9838
3 changed files with 100 additions and 9 deletions

View File

@ -0,0 +1,70 @@
/**
Keyword analysis for HackMyResume.
@license MIT. See LICENSE.md for details.
@module keyword-inspector.js
*/
(function() {
var _ = require('underscore');
var FluentDate = require('../core/fluent-date');
/**
Analyze the resume's use of keywords.
@class keywordInspector
*/
var keywordInspector = module.exports = {
/**
A unique name for this inspector.
*/
moniker: 'keyword-inspector',
/**
Run the Keyword Inspector on a resume.
@method run
@return An collection of statistical keyword data.
*/
run: function( rez ) {
// http://stackoverflow.com/a/2593661/4942583
function regex_quote(str) {
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, "\\$&");
};
var searchable = '';
rez.transformStrings( [], function trxString( key, val ) {
searchable += val;
});
return rez.keywords().map(function(kw) {
var regex = new RegExp( regex_quote( kw ), 'ig');
var myArray, count = 0;
while ((myArray = regex.exec( searchable )) !== null) {
count++;
}
return {
name: kw,
count: count
};
});
}
};
}());