Function to randomize a text string?


Author
Message
kurtisstewart1948
kurtisstewart1948
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 8, Visits: 23
Hi,

Is there an Inquisit function(s) that can take a subject's text input (e.g., Apples) and randomize the order of the letters (i.e., splepa)?

Thanks

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
Yes, you can build something like that using the string functions documented in the functions reference in the Inquisit documentation and e.g. a <list> element. Example:

<values>
/ nletters = 0
/ index = 0
/ input = ""
/ jumbled_output = ""
/ currentletter = ""
</values>

<expressions>
/ fill_list = if (values.index < values.nletters) {
    values.index+=1;
    list.randomizeletters.appenditem(values.index);
    expressions.fill_list;
    }
/ jumble = if (list.randomizeletters.unselectedcount > 0) {
    values.currentletter=substring(values.input, list.randomizeletters.nextindex-1, 1);
    values.jumbled_output=concat(values.jumbled_output, values.currentletter);
    expressions.jumble;
    }
</expressions>

<list randomizeletters>
/ selectionrate = always
</list>

<block myblock>
/ trials = [1-4=sequence(split, jumble)]
</block>

<openended split>
/ ontrialend = [values.input=openended.split.response;
    values.nletters=length(values.input);
    values.index=0;
    list.randomizeletters.reset();
    expressions.fill_list; ]
</openended>

<trial jumble>
/ ontrialbegin = [values.jumbled_output=""; expressions.jumble; ]
/ stimulusframes = [1=mytext]
/ validresponse = (57)
</trial>

<text mytext>
/ items = ("<%values.jumbled_output%>")
</text>

kurtisstewart1948
kurtisstewart1948
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 8, Visits: 23
Hi Dave,

This is great, thanks!

However, when I try to include that code into my script, the <%values.jumbled_output%> returns a blank string. I am trying to modify Olson and Fazio's Affective Priming Paradigm script so that participants first input a name and that this name and the jumbled version of the name are subsequently used as primes. Please let me know if you have any suggestions on how to do that.

Cheers,

Kurtis

Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
> However, when I try to include that code into my script, the <%values.jumbled_output%> returns a blank string.

Does the code I posted work for you? If so, there's something you missed when trying to incorporate it into your own script. What that is I cannot tell you without the actual code.

kurtisstewart1948
kurtisstewart1948
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 8, Visits: 23
The code that you posted works. I have attached my script. I either want the <%values.jumbled_output%> to be used as the second item in <item primes> or to be the item in <text prime2>. I have tried to incorporate it into both places but both return a blank string as the prime.

Any help with getting the jumbled output in the right place would be greatly appreciated.

Thanks!

Attachments
child-subliminal-priming.iqx (273 views, 30.00 KB)
Dave
Dave
Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)Supreme Being (1M reputation)
Group: Administrators
Posts: 13K, Visits: 104K
The problem is that you never execute expressions.jumble anywhere in your script. Hence values.jumbled_output is never set to anything. Do:

<openended childname>
/ ontrialend = [values.input=openended.childname.response;
    values.nletters=length(values.input);
    values.index=0;
    list.randomizeletters.reset();
    expressions.fill_list; expressions.jumble; ]
/required = true
/ mask = alphabetic
/charlimit = 10
</openended>

kurtisstewart1948
kurtisstewart1948
Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)Expert (1.2K reputation)
Group: Forum Members
Posts: 8, Visits: 23
It worked! Thank you,

Kurtis

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Reading This Topic

Explore
Messages
Mentions
Search