Howdy, Stranger!

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

Supported by

[open] Presenting items from a list

edited September 2015 in OpenSesame

Hi!

I'm very new to OpenSesame and am trying to build a simple word recognition task. I have a text file with hundreds of words and would like to: 1)import and shuffle the list 2)index items from the list 3)build study lists(all new words from the list) and build test lists (incorporating the previous study items and new items from the list. Below is what I have so far.

studyList1 should be 50 new words, testList1 should be studyList1 and 50 new words, studyList2 should be 50 new words, etc.

When I run it, nothing shows up on the screen, but it's not throwing any errors. Any ideas?

wordNum = 0

wordList = []

with open('words.txt','r') as f:
for line in f:
wordNum = wordNum+1
for word in line.split():
wordList.append(word)

import random
random.shuffle(wordList)

listLen = 50
list1 = wordList[:(listLen-1)]
list2 = wordList[listLen:((2*listLen)-1)]
studyList1 = list1
testList1 = studyList1 + list2

list3 = wordList[100:149]
list4 = wordList[100:199]
studyList2 = list3
testList2 = list4

list5 = wordList[200:249]
list6 = wordList[200:299]
studyList3 = list5
testList3 = list6

list7 = wordList[300:349]
list8 = wordList[300:399]
studyList4 = list7
testList4 = list8

exp.set('studyList1', studyList1)
exp.set('testList1', testList1)
exp.set('studyList2', studyList2)
exp.set('testList2', testList2)
exp.set('studyList3', studyList3)
exp.set('testList3', testList3)
exp.set('studyList4', studyList4)
exp.set('testList4', testList4)

Comments

  • edited 12:13PM

    Hi,

    As far as I see, you are not drawing anything to the screen, so why should it show anything?

    Aside from that, exp.set('studyList1', studyList1) won't work, because the method exp.setworks only with simple data types, such as numbers or strings. If you try to set a list, it will convert it to unicode. What you can do instead is something like this:

    # for every list
    exp.studylist1 = studylist
    

    Hope this helps.

    Eduard

    Buy Me A Coffee

Sign In or Register to comment.