If you are happy that the choice between the three types of stimuli is random from trial to trial (and hence likely slightly unbalanced within each subject), then you could insert a code component in Builder and put this code in the “Begin routine” tab, so that a stimulus type is selected and recorded at the start of each trial:
# choose a representation of one of the variable names:
options = ['word_sentence', 'word_construction', 'non_word']
shuffle(options) # randomise the list
stimulus_type = options # select the first entry
# record the choice in the data:
thisExp.addData('stimulus_type', stimulus_type) # need to record type what was chosen
stimulus_text = eval(stimulus_type) # now actually need its contents
thisExp.addData('stimulus_text', stimulus_text) # store it for convenience too
# even though it occurs in one of the other columns (makes
# analysis easier if in a single column).
You now have a variable called
stimulus_text which can be used as required. e.g. put
$stimulus_text in a text component, set to update on every routine.
Make sure that the code component is above the text component, so that the variable is chosen before the text component needs to refer to it.
Some of this stuff is actually a little bit tricky if you are not familiar with programming, and Python in particular. i.e. here we are using string representations of variable names (e.g.
'word_sentence') for certain purposes (e.g. storing in the data file). But we then need to convert that string of characters into the actual variable name (
word_sentence without the quotes). That is done using the
stimulus_type is a variable that contains just a literal string of characters like
'word_sentence'. When we “evaluate” that string of characters, we turn it into the actual variable name
word_sentence (no quotes), that actually points to your real sentence content (
'Hello world' or whatever). This distinction may or may not make sense to you, but it is one of the flexible things about Python that makes it easy to achieve some things like this.