Non-breaking space in items?

PennController for IBEX Forums Support Non-breaking space in items?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #11006
    mawilson
    Participant

    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 displayed these words, rather than displaying these 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 in main.js using the ability of the DashedSentence 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 1 month ago by mawilson. Reason: attempt to fix formatting
    #11008
    mawilson
    Participant

    I 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.

    • This reply was modified 1 month ago by mawilson. Reason: make MWE more minimal
    • This reply was modified 1 month ago by mawilson. Reason: fix formatting
    • This reply was modified 1 month ago by mawilson.
    • This reply was modified 1 month ago by mawilson.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.