What I tried was using defined integer for the number of dashes to cover the words.
This solved the problem of "different number of dashes masking different word length".
You can see that I put '6' instead of len(word) to do so.
sentenceList = sentence.split()
# this breaks your sentence's single string of characters into a list of individual
# words, e.g. 'The quick brown fox.' becomes ['The', 'quick', 'brown', 'fox.']
# keep track of which word we are up to:
wordNumber = -1 # -1 as we haven't started yet
# now define a function which we can use here and later on to replace letters with '-':
def replaceWithdash(textList, currentWordNumber):
dashSentence = ''
for index, word in enumerate(textList): # cycle through the words and their index numbers
if index != currentWordNumber:
dashSentence = dashSentence + '-' * 6 + ' ' # add a string of dash characters
dashSentence = dashSentence + word # except for the current word
return dashSentence # yields the manipulated sentence
# now at the very beginning of the trial, we need to run this function for the
# first time. As the current word number is -1, it should make all words '-'.
# Use the actual name of your Builder text component here:
text.text = replaceWithdash(sentenceList, wordNumber)
# In the Builder interface, specify a "constant" value for the text content, e.g.
# 'test', so it doesn't conflict with our code.
With this, I could make the length an array of the dashes constant before the first word is revealed.
But to accomplish true 'moving window', array(x,y position) of the dashes should stay still. This is not achieved because once a word is shown, their true length is revealed and somehow their variable length influence the array of other yet to be revealed(or masked again) dashes to move a little bit. I attached the screenshots to describe this. FYI the characters are Korean.
Above is the first screen with words covered by identical number(6) of dashes. So it does not reveal any length information of the masked sentence.
Two screens compared after different length of words are revealed. You can see that the position of the remaining dashes when 4-letter-word(count a letter like Chinese character) is revealed is different from that of 2-letter-word. I drew red lines to show that it has moved.
Right now, I couldn't think of a way to solve this within code component. I also tried putting a white line image in the background and unmasking each word on that line. But this poses another methodological problems(e.g. small portion of lines shown at the left side of the very first word, which harms the cognitive presumption that there should be no masking at the left of the very first word of the sentence).
Thank you for your time.