MemEOL: Difference between revisions
From Desal Wiki
imported>WikiAdmin No edit summary |
imported>WikiAdmin No edit summary |
||
| Line 47: | Line 47: | ||
} | } | ||
*/ | |||
function computePreferenceScores(preferences){ | |||
console.log("preferences: " + String(preferences)); | |||
var arrayLength = preferences.length; | |||
var centroidWeights = new Array(arrayLength); | |||
for (var i=0; i < arrayLength; i++) { | |||
centroidWeights[preferences[i]-1] = centroidWeightMagicNumbers[i+1]; | |||
console.log(String(preferences[i]-1) + " | " + String(centroidWeightMagicNumbers[i+1])); | |||
} | |||
//now multiply each centroid weight by each magic number to get scores | |||
var j=0; | |||
var scores= new Array(); | |||
for (var item in dictionaryMagicNumbers) { | |||
if(item == 'Options') continue; | |||
var k=0; | |||
scores[j]=0; | |||
for (var subItem in dictionaryMagicNumbers[item]) { | |||
console.log(String(item) + " - " + String(j) +"-" + String(k) +": "+ String(dictionaryMagicNumbers[item][subItem]) +" | "+ String(centroidWeights[k])); | |||
scores[j] = scores[j] + centroidWeights[k] * dictionaryMagicNumbers[item][subItem]; | |||
k++; | |||
} | |||
console.log('Score: ' + String(scores[j])); | |||
j++; | |||
} | |||
//now that we have the scores we need to check them and display the correct output | |||
} | } | ||
//prefereces are coded to be 0-4 not 1-5 | //prefereces are coded to be 0-4 not 1-5 | ||
function getPreferences(){ | function getPreferences(){ | ||
| Line 85: | Line 104: | ||
.click(function( event ) { | .click(function( event ) { | ||
event.preventDefault(); //lock the button for now. | event.preventDefault(); //lock the button for now. | ||
var preferences = getPreferences(); | |||
var scores = computePreferenceScores(preferences); | |||
}); | }); | ||
}); | }); | ||
Revision as of 00:16, 9 December 2014
Introduction text