You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While testing TagPies with a document corpus I found that building the hash map prioHash in TagPies.js file can have issues when word.key conflicts with JavaScript standard attributes for Array object.
In code below when word.key = "length" or one of the other JS attributes for arrays (like 'map', 'slice', etc.) then the line if(typeof prioHash[word.key] == "undefined") returns false even though the key is not present in prioHash, resulting in error in the subsequent line prioHash[word.key].push(word);
My first and rather basic solution is to create a list of possible conflict terms and catch them before testing the hash map. I modify the terms by adding a space at end to avoid the conflict.
// var problemTerms = ['length', 'map', 'filter', 'slice', 'sort'];
for(var i = 0; i < tags1.length; i++) {
var word = tags1[i];
globalHash[word.id] = word;
//if (problemTerms.indexOf (word.key) > -1) {
// word.key += ' ';
// //console.log ("!!! problem term: " + word.key);
//}
if(typeof prioHash[word.key] == "undefined") {
prioHash[word.key] = [];
freqHash[word.key] = 0;
}
prioHash[word.key].push(word); // Error here if word.key is one from problemTerms
freqHash[word.key] += word.value;
if(word.value > maxFreq) {
maxFreq = word.value;
}
if(word.value < minFreq) {
minFreq = word.value;
}
}
Thanks.
The text was updated successfully, but these errors were encountered:
While testing TagPies with a document corpus I found that building the hash map
prioHash
inTagPies.js
file can have issues whenword.key
conflicts with JavaScript standard attributes for Array object.In code below when
word.key = "length"
or one of the other JS attributes for arrays (like 'map', 'slice', etc.) then the lineif(typeof prioHash[word.key] == "undefined")
returns false even though the key is not present in prioHash, resulting in error in the subsequent lineprioHash[word.key].push(word);
My first and rather basic solution is to create a list of possible conflict terms and catch them before testing the hash map. I modify the terms by adding a space at end to avoid the conflict.
Thanks.
The text was updated successfully, but these errors were encountered: