Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Random Sentences followed by paired Question

edited January 2016 in OpenSesame

Hi, I am doing a reading study where the participants read sentences (random order) and answer paired comprehension questions. I have currently extracted a list looking like this from a .csv file with all the sentences, questions, item number and answer.

import csv 
image_path = exp.get_file('Sentences.csv')
with open(image_path, 'rU') as csvfile:
    reader = csv.DictReader(csvfile, delimiter=',')
    full_list = list(reader)
    for row in full_list:
        print row

{'Answer': 'y', 'Question': 'Was the roommate preparing himself?', 'Sentence Number': '6', 'Sentences': 'After the roommate prepared Kevin rapped his wine glass with his knife.'}
{'Answer': 'n', 'Question': 'Was Alec rushed?', 'Sentence Number': '7', 'Sentences': 'While Dale rushed Alec inspected some shirts at the department store.'}
{'Answer': 'n', 'Question': 'Was Kari raced?', 'Sentence Number': '8', 'Sentences': 'While the woman raced Kari strode ahead in the last lap around the track.'}
{'Answer': 'y', 'Question': 'Was the toy box messy?', 'Sentence Number': '9', 'Sentences': 'It was very hard to find the lorry inside of the messy toy box.'}
{'Answer': 'y', 'Question': 'Was Joel selling a dining set?', 'Sentence Number': '10', 'Sentences': 'Joel included a table in the dining set he was selling.'}

How to I go about looping over this list and presenting the sentences in random order, but maintaining the bond with the paired question and answer?

Comments

  • edited January 2016

    Hi,

    The easiest thing will be to just put the questions on the same line as your sentences in the csv file. So one sentence may look like this: "While Dale rushed Alex inspected some shirts..Was Alex rushed?". These sentences can then be put in a list with the file.readlines() command (or in your case a dictionary). With the random.shuffle(full_list) command you randomize the order of appearance.

    Now, to present the sentence, we first have to cut it in half. Note that ".." separated the sentence from the followup question, so:

     sentence_and_question = full_list.pop(0)
     question = sentence_and_question.split('..')[1] 
     sentence = sentence_and_question.split('..')[0]
    

    Hope this helps.

    Cheers,

    Josh

  • edited 7:55PM

    Hi,

    (Just before I wanted to send this response, I saw that Josh already answered. But anyway, I don't want to have typed this for nothing, so I'll post it as well, and you can choose whichever solution you prefer)

    First you randomize the list:

    import random
    random.shuffle(full_list)
    

    Then, you have to create some sort of loop that repeats whatever should be happening during a trial. For this matter, I recommend using a loop-sequence structure (see the opensesame documentation, if you don't know what this means).
    In the sequence, you have to have an inline_script, in which you pick the information that you are going to use on that specific trial. For example, by doing this:


    trial_info = full_list.pop(0)

    This will always take the first entry of your dictionary. Since you shuffled earlier, you don't need to worry about randomization any more. The following steps depend a lot on what exactly it is that you want to present. But as you have all relevant information in your dictionary trial_info, you should have everything that you need to make it work.

    Good luck,

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games