gender-science-iat.py 1.61 KB
Newer Older
Xiaoying Pu's avatar
Xiaoying Pu committed
1
from random import randint
2

Xiaoying Pu's avatar
Xiaoying Pu committed
3 4
male = "Male, Boy, Father, Man, Grandpa, Husband, Son, Uncle"
female = "Female, Girl, Aunt, Daughter, Wife, Woman, Mother, Grandma"
5

Xiaoying Pu's avatar
Xiaoying Pu committed
6 7
science = "Science, Physics, Chemistry, Math, Geology, Astronomy, Engineering"
arts = "Arts, Philosophy, Humanities, Literature, English, Music, History"
8 9

# First element is the name of the category
Xiaoying Pu's avatar
Xiaoying Pu committed
10

11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
male = male.split(", ")
female = female.split(", ")
science = science.split(", ")
arts = arts.split(", ")


# TODO: formatting of message, 

gender = [male, female]
arts_n_science = [science, arts]


to_java = []


# msg format:
# type, stimulus, condition, randomize-block, correct, default-compare, response #1, response #2 ...

msg_type = 2 	# string 
rand_blk = 1 	# doesn't really help but 'tis there

# Wait...... putting randomize-block = 1 will randomize all trials...

Xiaoying Pu's avatar
Xiaoying Pu committed
34
def gen_a_row(category, other, condition, i, default_compare):
35 36
	"""
	see msg format
Xiaoying Pu's avatar
Xiaoying Pu committed
37 38
	category: list of stimuli, like Biology, Physics, Math.... 
	i: index 
39 40 41
	hardcoded:
		type
		*** need to leave randomize-block __blank__
Xiaoying Pu's avatar
Xiaoying Pu committed
42 43
	return: 
		a row of comma separated stimulus
44
	"""
Xiaoying Pu's avatar
Xiaoying Pu committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
	
	assert 0 <= i and i < len(category)

	correct = randint(0, 1) 		# which one is correct, 0 or 1?
	response_1 = category[0]
	response_2 = other 
	if (correct == 1):
		response_1, response_2 = response_2, response_1

	result = [str(msg_type), category[i], \
	condition, str(1), \
	str(correct + 1), str(default_compare), \
	response_1, response_2]

	return ",".join(result)


for i in range(len(female)):
	to_java.append( gen_a_row(female, "Male", "Gender",  i, 2))
	to_java.append( gen_a_row(male, "Female", "Gender", i, 1))
Xiaoying Pu's avatar
Xiaoying Pu committed
65
print to_java