rulezb
Version:
A Business Rule Engine for rule them all
23 lines • 867 B
JavaScript
exports.test2 = {
returnType:function(data){
console.log(data);
},
rules:[
function(data){
maxTimes = 0;
tokensNormalizedAndCount = {}
tokens = data.text.replace().split(" ");
for (w in tokens){
lowertoken = tokens[w];//.toLowerCase();
if (tokensNormalizedAndCount[lowertoken]== undefined){
tokensNormalizedAndCount[lowertoken]=1;
continue;
}
tokensNormalizedAndCount[lowertoken]++;
if(tokensNormalizedAndCount[lowertoken] > maxTimes)
maxTimes = tokensNormalizedAndCount[lowertoken];
}
{"tokens":tokensNormalizedAndCount, "maxTimes":maxTimes};
},
]
};