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

#5540
mrhelfrich
Participant

Hello again,

I am trying to learn something about the code that has been posted here and would like to try and understand how the code you have previously posted that forces special characters to always appear outside of the masks works so that I can remove it or make changes to it in the future. I have two pieces of code that may be useful for my experiment except they have they don’t mask special characters and I have no idea why. The first one should be the same as the code posted previously:

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);
}

(Sorry about the formatting, whenever I try using the tilde key to put things into code format it just makes it worse and it appears I have a limited time to edit my replies before the system locks me out)

The other piece of code I ended up changing was previously for changing the masking character from underscores to hyphens. I was seeing if I could make no mask appear at all, so that participants wouldn’t be able to guess at how long each word was until it appeared on screen but whatever I did ended up breaking everything in a way that could potentially be useful for me in the future since it makes only one word appear on screen at a time, like in a word-by-word style experiment. However it still has the same issue of not masking special characters which looks odd.

showWord = (s,i) => ‘<p style=”font-family: monospace;”>’+s.map((w,n)=>`
<span>${w.replace(/^\s*(\w+).*$/,”$1″).replace(/(.)/g,(i===n?”$1″:” “))}</span>${w.replace(/^\s*\w+/,”)}`).join(‘ ‘)+'</p>’

dashed = (name, sentence) => {
let words = sentence.split(‘ ‘), maxwidth = 0;
words.map(w=>maxwidth=Math.max(w.length,maxwidth));
return [
[newText(name, showWord(words,null,maxwidth)).print()],
…words.map( (w,i) => [newKey(${name}-${i}-${w},” “).log().wait() , getText(name).text(showWord(words,i,maxwidth))] ),
[newKey(${name}-last,” “).log().wait()]
].flat(1);
}

I would like to at least understand what portion of these two pieces of code causes the special characters to be ignored by the masking.

Thanks again for all of your help, I really appreciate it,
Max