Skip to content

Commit 779a101

Browse files
committed
test: order of (un)grammtical items more random
1 parent 348717e commit 779a101

1 file changed

Lines changed: 48 additions & 17 deletions

File tree

test/stimuli.zm

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,39 @@ int find_string_index(string[] haystack, string needle) {
2929
return ret;
3030
}
3131

32+
TestType[] shuffle_order = {
33+
TT_GRAMMATICAL,
34+
TT_GRAMMATICAL,
35+
TT_GRAMMATICAL,
36+
TT_GRAMMATICAL,
37+
TT_UNGRAMMATICAL,
38+
TT_UNGRAMMATICAL,
39+
TT_UNGRAMMATICAL,
40+
TT_UNGRAMMATICAL
41+
}
42+
43+
int test_type_max_consecutive() {
44+
int max_num_consecutive = 1;
45+
int num_consecutive = 1;
46+
int i = 1;
47+
48+
while(i < shuffle_order.size) {
49+
if (shuffle_order[i] == shuffle_order[i-1]) {
50+
num_consecutive++;
51+
if (num_consecutive > max_num_consecutive) {
52+
max_num_consecutive = num_consecutive;
53+
}
54+
}
55+
else {
56+
num_consecutive = 1;
57+
}
58+
i++;
59+
}
60+
61+
return max_num_consecutive;
62+
}
63+
64+
3265
LanguageType determine_language(string stimulus) {
3366
LanguageType ret = LANGUAGE_NOT_SPECIFIED;
3467
if (find_string_index(l1_stimuli, stimulus) != -1) {
@@ -165,37 +198,35 @@ set_stimulus_direction() {
165198

166199
void
167200
prepare_test_items() {
168-
int i = 0;
169201
string GRAMMATICAL = "grammatical";
170202
string UNGRAMMATICAL = "ungrammatical";
171203

172204
string grammar_first = expdb.participant.get_enum_field("first_grammar");
173205

174-
while (i < NUM_TEST_TRIALS) {
175-
bool is_even = i % 2 == 0;
176-
bool is_odd = i % 2 == 1;
206+
println("shuffeling, " + grammar_first + " ncons = " + test_type_max_consecutive());
207+
while ((grammar_first == GRAMMATICAL && shuffle_order[0] != TT_GRAMMATICAL)
208+
|| (grammar_first == UNGRAMMATICAL && shuffle_order[0] != TT_UNGRAMMATICAL)
209+
|| (test_type_max_consecutive() != 2)) {
210+
println("shuffeling");
211+
shuffle_order.shuffle(0, -1);
212+
}
177213

214+
int i = 0;
215+
while (i < NUM_TEST_TRIALS) {
178216
TestItem item;
179-
180-
if (is_even && grammar_first == GRAMMATICAL) {
217+
if (shuffle_order[i] == TT_GRAMMATICAL) {
181218
item = create_grammatical();
182219
}
183-
else if(is_odd && grammar_first == GRAMMATICAL) {
220+
else if (shuffle_order[i] == TT_UNGRAMMATICAL) {
184221
item = create_ungrammatical();
185222
}
186-
else if(is_even && grammar_first == UNGRAMMATICAL) {
187-
item = create_ungrammatical();
188-
}
189-
else if(is_odd && grammar_first == UNGRAMMATICAL) {
190-
item = create_grammatical();
191-
}
192-
else{
193-
print_error(
194-
"Oops unexpected parameters for choosing stimuli based on grammar\n"
195-
);
223+
else {
224+
print_error("Oops test items ain't grammatical nor ungrammatical");
225+
flush_error();
196226
}
197227

198228
append_test_item(test_items, item);
229+
199230
i++;
200231
}
201232
if (test_items.size != NUM_TEST_TRIALS) {

0 commit comments

Comments
 (0)