Score Word Responses Demo Experiment Run Experiment

Score Word Responses

Jaap Murre

Function to help you score free recall answers as obtained with the largeinput() function. If you run it, you won't see any output. First open the console window (with F12 on Windows or Cmd + Option + J on a Mac). The output will appear there.

Note that you must copy and paste the function in this script to your own script before anything in your script. Alternatively, you can scroll down in editscript to the Included Scripts section and drag this script to the right (and press Save). This will accomplish the same thing.

If you are a registered user and signed in, you can here copy this script and its stimuli to your own account, where you can edit it and change it in any way you want.

It is absolutely free to register (no credit card info asked!). You can then instantly copy this experiment with one click and edit it, change its accompanying texts, its landing page, stimuli, etc. Invite your colleagues, friends, or students to check out your experiment. There is no limit on how many people can do your experiment, even with a free account.

The catch? There is no catch! Just keep in mind that with a free account, you cannot collect data. For teaching that is usually not a problem. For research, prepaid data collection (unlimited subjects) starts as low as €10.00 for a 10-day period.

// Scores all 'recalled' words and returns an array of 0 and 1 (recalled).
// Only words with letters a-z and A-Z will be scored (e.g., not i-umlaut).
// Criterion is the percentage that may be wrong according to the Levenshtein
// distance relative to the correct word's length. Default: 20% or one letter
// wrong in five-letter word. For short words (e.g., 5 letters), this is a good
// setting. For much longer words/sentences, a higher criterion may be used.


// Usage:
//    var w = ['one','two','three'],
//        s = "two,  ; one  ,  five";
//    scoreWordsRecalled(w,s); // Call with default criterion
// Returns [1,1,0]
function scoreWordsRecalled(words,recalled,criterion) 
{
    criterion = criterion || 0.20; // 20% difference is still OK, e.g., hony instead of honey
    
    var i, j, r = recalled.split(/[^A-Za-z]+/), result = [], score;
    
    for (i = 0; i < words.length; i++) 
    { 
        score = 0;
        for (j = 0; j < r.length; j++)
        {
            if ( distance(words[i],r[j]) <= criterion*words[i].length) {
                score = 1;
                break;
            }
        }
        result.push(score);
    }    
    
    return result;
}


    var correct_words = ['one','two','three'],
        subject_response = "Two,  ; one  ,  five"; // N.B. This is a string. E.g., from larginput()

    var result = scoreWordsRecalled(correct_words,subject_response); // Call with default criterion
    
    var i, sum = 0;
    for (i = 0; i < result.length; i++) {
        sum = sum + result[i];
    }
    
    console.log("Result:",result,sum);
This experiment has no files of this type
This experiment has no files of this type
This experiment has no files of this type
This experiment has no YouTube links
This experiment has no files of this type