PennController for IBEX › Forums › Support › Non-breaking space in items?
- This topic has 1 reply, 1 voice, and was last updated 6 months, 2 weeks ago by mawilson.
-
AuthorPosts
-
March 25, 2024 at 6:19 pm #11006mawilsonParticipant
I’m making an experiment that is mostly centered word-by-word SPR, but for a couple of items I want to present two short words together at once. I tried doing this by adding
between the words (with no space), but that just literally displayedthese words
, rather than displayingthese words
on the same screen. Is there a way I can do this by modifying the examples in the stimuli file, rather than having to manually set this up inmain.js
using the ability of theDashedSentence
controller to take a list of strings?I’ve put up a MWE here: https://farm.pcibex.net/r/UiwhPx/. Here’s the code for it:
main.js
:PennController.ResetPrefix(null) Sequence( 'example', SendResults() ) Template( 'example.csv', item => ['example', 'DashedSentence', {s: item.sentence, display: 'in place'} ] )
example.csv
:sentence "In this sentence, I would like these words to be displayed together."
- This topic was modified 6 months, 2 weeks ago by mawilson. Reason: attempt to fix formatting
March 26, 2024 at 6:27 pm #11008mawilsonParticipantI ended up figuring something out; here’s the code I used in case it’s of use to anyone else.
PennController.ResetPrefix(null) Sequence( 'example', SendResults() ) Template('example.csv', item => { var sentence = item.sentence.split(' ') var s_array = [] for (var word of sentence) { word = word.replace(' ', ' ') s_array.push(word) } sentence = s_array return [ 'example', 'DashedSentence', {s: sentence, display: 'in place'} ] })
The basic idea is to modify the item prior to running each trial. I split the sentence on spaces (which won’t split the literal
). Replace the
s with actual spaces, and then pass that array to the controller instead of the sentence stored in the csv. -
AuthorPosts
- You must be logged in to reply to this topic.