Reply To: DashedSentence in a PennController trial

PennController for IBEX Forums FAQ / Tips DashedSentence in a PennController trial Reply To: DashedSentence in a PennController trial

#5436
mrhelfrich
Participant

Hello,

I am trying to adapt the code from some of the replies in this thread for an experiment but I don’t have any coding experience.

I am currently using the code in response #5236 to display sentences but I do not want to have the punctuation marks be displayed like that code specifically asks for. I tried using the original code in the opening post but when I use that code it doesn’t work with the Template command mentioned in response #5252.

For clarity the important part of my code is this:

showWord = (s,i) => '<p>'+s.map((w,n)=>`
        <span${(i===n?"":' style=\'border-bottom:solid 1px black;\'><span style=\'visibility:hidden;\'')}'>
        ${w.replace(/^\s*(\w+).*$/,"$1")}${(i===n?"":'</span>')}</span>${w.replace(/^\s*\w+/,'')}`).join(' ')+'</p>'   

dashed = (name, sentence) => {
    let words = sentence.split(' ');
    return [
        [newText(name, showWord(words)).print()], 
        ...words.map( (w,i) => [newKey(${name}-${i}-${w}," ").log().wait() , getText(name).text(showWord(words,i))] ),
        [newKey(${name}-last`," ").log().wait()]
    ].flat(1);
}

I would like it function like the original code in the first post, i.e. not displaying punctuation marks outside of the masked words.

While I suspect I will have many more questions, one other related thing that I would like to do if possible would be to make the masking that appears (the series of underscores) appear to be the same length for all words so that a participant cannot look at the entirely masked sentence and guess how long each word is. The experiment I am setting up will use two sentence passages that are up to 30 words in length and it is very obvious currently where words like "a" and "to" are.

Example: instead of a sentence that says "A local man is in a great amount of debt due to gambling." appearing as "_ _____ ___ __ __ _ _____ ______ __ ____ ___ __ _________" it would appear uniform until the words were being unmasked such as "_____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____"

Thank you very much for your time as well as this very useful tool.
Max