Millisecond Forums

Counting words in openended

By Oliver - 9/8/2011

Is there a way to count words in openended while subjects are writing and using the count as a condition for ending the trial? More concretely, I want to modify the Picture Story Exercise module posted on the Inquisit website so that participants have to write a minimum of 100 words for each openenden iteam before they can move on to the next trail.

By Dave - 9/8/2011

You'll want to use /isvalidresponse along with a bunch of (recursive*) <expressions>. Not easy to do, but should be possible. (I'd recommend counting the number of spaces.) Using the number of characters as criterion would be considerably easier (/range attribute or use the length() function).



*cf. the Self-Paced Reading script available from the Task Library.

By Dave - 9/9/2011

And just for fun here's a little word-counting algorithm that doesn't require any recursion:

/ mysentence = "The quick brown fox jumps over the lazy dog."

/ nwords = length(values.mysentence)-length(replaceall(values.mysentence," ",""))+1

<text mytext>
/ items = ("The sentence ~"<%values.mysentence%>~" contains <%expressions.nwords%> words.")