varying word presentation depending on length

PennController for IBEX Forums Support varying word presentation depending on length

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6375
    yanaib
    Participant

    Hi,

    I can’t quite figure out how to add varying word presentation time to dashedsentence (in speeded acceptability mode). I would like to display every word up to 12 characters long for 250ms, and then add 20 extra ms for every character over 12, i.e. a word of 14 characters will be displayed for 290ms.

    I’ve added the following to the wordPauseTimeout() function (line 152, I think).:

    if (t.words[t.currentWord].length > 12) {
    var extraTime = (t.words[t.currentWord].length – 12) * 20;
    t.wordTime = t.wordTime + extraTime;
    }

    Judging from console.log, it looks like it’s at least executed at the right time, but this updated controller breaks the word-by-word presentation: the whole sentence is presented, and then a few first words are removed left to right one by one. I’m not sure exactly what I’m getting wrong, and I’m especially confused as to why this disrupts word-by-word presentation: I wrote an if statememnt specifically to isolate it from the rest of the code so that it at least doesn’t break it if it fails to work.

    I would appreciate any help!

    Many thanks

    Yana

    #6377
    Jeremy
    Keymaster

    Hi Yana,

    I think you’re doing the right thing inserting your code in the wordPauseTimeout function, but when I open the js file I see that line 152 is part of the wordTimeout function, so I just want to make sure you’re editing the right function.

    However I’m afraid that directly modifying t.wordTime will cause problems after encountering the first over-12-character word, because the subsequent words will inherit the extra duration. Here is how I rewrote the whole if statement, and it seems to be working smoothly:

    if (this.mode == "speeded acceptability") {
        var t = this;
        function wordTimeout() {
            t.blankWord(t.currentWord);
            ++(t.currentWord);
            if (t.currentWord >= t.stoppingPoint)
                t.finishedCallback([[["Sentence (or sentence MD5)", t.sentenceDesc]]]);
            else
                t.utils.setTimeout(wordPauseTimeout, t.wordPauseTime);
        }
        function wordPauseTimeout() {
            t.showWord(t.currentWord);
            t.utils.clearTimeout(wordPauseTimeout);
            let duration = t.wordTime;
            if (t.words[t.currentWord].length > 12) {
                var extraTime = (t.words[t.currentWord].length - 12) * 200;
                duration += extraTime;
            }
            t.utils.setTimeout(wordTimeout, duration);
        }
        wordPauseTimeout();
    }

    I used 200 so I could clearly tell when the extra time was added to the normal display time. For reference, here are the parameters I used to test the DashedSentence:

    {
      s: "Extralongitudinal is not a word that makes much anticonstitutional sense",
      wordTime: 250,
      mode: "speeded acceptability"
    }

    Jeremy

    #6378
    yanaib
    Participant

    Thanks a lot for the explanation and your solution, this works seamlessly!

    Yana

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.