Skip to content

Commit

Permalink
Merge pull request #25 from UiL-OTS-labs/nad_entropy_fixes_aug24
Browse files Browse the repository at this point in the history
Nad entropy fixes aug24
  • Loading branch information
maartenuni authored Sep 2, 2022
2 parents e6f77d0 + ded006e commit 774a96f
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 161 deletions.
2 changes: 1 addition & 1 deletion nad_entrophy/nad.zp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Experiment experiment
on_event:entry()
{
entry_page.set_text(WELCOME_TEXT);
entry_page.action(this, 0s);
entry_page.action(this, 1s);
}
}

Expand Down
10 changes: 6 additions & 4 deletions nad_entrophy/test/instructions.zm
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const string PRE_TRAIN_INSTRUCTION =
"verder te gaan.";

const string PRE_TRAIN_INSTRUCTION_SHORT =
"Je gaat nu verder met het luisteren naar klanken reeksen uit de buitenaardse taal.\n"
"Je gaat nu verder met het luisteren naar klankenreeksen uit de buitenaardse taal.\n"
"Druk op <b>start</b> om verder te gaan.";

const string TRAIN_PROMPT = "Luister naar de buitenaardse klanken.";
const string TRAIN_PROMPT = "Luister naar de buitenaardse klankenreeksen.";

const string PRE_TEST_INSTRUCTION =
"Je gaat nu een aantal vragen beantwoorden.\n\n"
Expand All @@ -30,7 +30,7 @@ const string PRE_TEST_INSTRUCTION_NEW =
"waarvan het waarschijnlijker is dat deze uit de buitenaardse taal komt "
"die je net hoorde.\n\n"
"Niet alle klanken in deze test zijn voorgekomen in de taal die je net "
"hoorde, maar je kunt nog steeds de klankenreeks selecteren dat het meest "
"hoorde, maar je kunt nog steeds de klankenreeks selecteren die het meest "
"waarschijnlijk uit deze taal komt.\n\n"
"Antwoord zo snel en accuraat als mogelijk alsjeblieft.\n\n"
"Druk op <b>start</b> om verder te gaan.";
Expand All @@ -43,5 +43,7 @@ const string TEST_QUESTION =
"Van welke klankenreeds is het meer waarschijnlijk dat deze uit de buitenaardse taal komt?\n\n"
"Kies de eerste of tweede klankenreeks door op de corresponderende toets te drukken.";

const string CONFIDENCE_QUESTION = "Hoe zeker ben je van je keuze:";
const string CONFIDENCE_QUESTION =
"Hoe zeker ben je van je keuze:\n"
"1 = Onzeker, 6 = Zeker";

262 changes: 109 additions & 153 deletions nad_entrophy/test/stimuli.zm
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
/******************************************************************************\
FILE: stimuli.zm
AUTHOR: Theo Veenker <[email protected]>
ADAPTED BY: Silvia Radulescu
LAST MODIFIED: 2015-03-17

DESCRIPTION:

Defines the formats of item table(s) and provides the actual content of
the item table(s) i.e. stimulus information.


HISTORY:
2011-10-25 TV Created.

\******************************************************************************/

import condition;


enum TestType {
TRAINED_FIRST, // In the the test phase the trained is presented first
FOREIGN_FIRST // In the test phase the foreign item is presented first
}
enum GrammarType {
GRAM_L1, // Grammar compatible with L1
GRAM_L2 // Grammar compatible with L2
};

enum ResponseType {
FIRST,
SECOND
}
};


// Item table record.
Expand All @@ -37,7 +21,7 @@ record TrainItem
CondEntropy entropy; // entropy of item
CondLang language; // L1 or L2
string sndfn; // stimulus word sound filename
}
};

void print_train_items(TrainItem[] items, bool header) {
int i = 0;
Expand All @@ -56,32 +40,14 @@ void print_train_items(TrainItem[] items, bool header) {
}
}

record TestItem {
int id;
TestType test_type; // The type of test trial foreign or trained
string fn1; // file of the first stimulus
string fn2; // file of the second stimulus
};

void print_test_items(TestItem[] items, bool header) {
int i = 0;
if (header)
println("id test_type file1 file2");

while (i < items.size) {
println(string(items[i].id) + " " +
items[i].fn1 + " " +
items[i].fn2 + " " +
items[i].test_type);
i++;
}
}

record CheckinItem
{
int id;
string value;
}
/*
* The training stimuli are presented in these 3 lists, each
* list corresponds to a block.
*/
TrainItem[] training_items1 = {};
TrainItem[] training_items2 = {};
TrainItem[] training_items3 = {};


// Training items of language 1 with low entropy
Expand Down Expand Up @@ -229,67 +195,6 @@ TrainItem[] items_high_l2 = {
{54, 0, EN_HIGH, LANG_L2, "tep_zuk_jik"}
}

string[] familiar_l1 = {
"rak_bap_toef",
"rak_gom_toef",
"rak_ves_toef",
"sot_bap_jik",
"sot_gom_jik",
"sot_ves_jik",
"tep_bap_lut",
"tep_gom_lut",
"tep_ves_lut",
};

string[] familiar_l2 = {
"rak_bap_lut",
"rak_gom_lut",
"rak_ves_lut",
"sot_bap_toef",
"sot_gom_toef",
"sot_ves_toef",
"tep_bap_jik",
"tep_gom_jik",
"tep_ves_jik"
};

string[] new_l1 = {
"rak_bug_toef",
"rak_gak_toef",
"rak_zim_toef",
"sot_bug_jik",
"sot_gak_jik",
"sot_zim_jik",
"tep_bug_lut",
"tep_gak_lut",
"tep_zim_lut"
};

string[] new_l2 = {
"rak_bug_lut",
"rak_gak_lut",
"rak_zim_lut",
"sot_bug_toef",
"sot_gak_toef",
"sot_zim_toef",
"tep_bug_jik",
"tep_gak_jik",
"tep_zim_jik"
};

/*
* The training stimuli are presented in these 3 lists, each
* list corresponds to a block.
*/
TrainItem[] training_items1 = {};
TrainItem[] training_items2 = {};
TrainItem[] training_items3 = {};

TestItem [] test_items1 = {};
TestItem [] test_items2 = {};
TestItem [] test_items3 = {};


void append_train_item(TrainItem[] array, TrainItem item) {
array.size = array.size + 1;
array[array.size - 1] = item;
Expand Down Expand Up @@ -392,43 +297,104 @@ void prepare_training_items() {
prepare_training_lists(training_items);
}

/*
* Test items
*/
record TestItem {
int id;
GrammarType g1;
string fn1;
GrammarType g2;
string fn2;
};

void print_test_items(TestItem[] items, bool header) {
int i = 0;
if (header)
println("id test_type file1 file2");

while (i < items.size) {
println(string(items[i].id) + " " +
items[i].g1 + " " +
items[i].fn1 + " " +
items[i].g2 + " " +
items[i].fn2
);
i++;
}
}

TestItem[] test_items_fam = {
{1, GRAM_L1, "rak_bap_toef", GRAM_L2, "rak_bap_lut"},
{2, GRAM_L1, "rak_gom_toef", GRAM_L2, "rak_gom_lut"},
{3, GRAM_L1, "rak_ves_toef", GRAM_L2, "rak_ves_lut"},
{4, GRAM_L1, "sot_bap_jik", GRAM_L2, "sot_bap_toef"},
{5, GRAM_L1, "sot_gom_jik", GRAM_L2, "sot_gom_toef"},
{6, GRAM_L1, "sot_ves_jik", GRAM_L2, "sot_ves_toef"},
{7, GRAM_L1, "tep_bap_lut", GRAM_L2, "tep_bap_jik"},
{8, GRAM_L1, "tep_gom_lut", GRAM_L2, "tep_gom_jik"},
{9, GRAM_L1, "tep_ves_lut", GRAM_L2, "tep_ves_jik"}
};

TestItem[] test_items_new = {
{1, GRAM_L1, "rak_bug_toef", GRAM_L2, "rak_bug_lut"},
{2, GRAM_L1, "rak_gak_toef", GRAM_L2, "rak_gak_lut"},
{3, GRAM_L1, "rak_zim_toef", GRAM_L2, "rak_zim_lut"},
{4, GRAM_L1, "sot_bug_jik", GRAM_L2, "sot_bug_toef"},
{5, GRAM_L1, "sot_gak_jik", GRAM_L2, "sot_gak_toef"},
{6, GRAM_L1, "sot_zim_jik", GRAM_L2, "sot_zim_toef"},
{7, GRAM_L1, "tep_bug_lut", GRAM_L2, "tep_bug_jik"},
{8, GRAM_L1, "tep_gak_lut", GRAM_L2, "tep_gak_jik"},
{9, GRAM_L1, "tep_zim_lut", GRAM_L2, "tep_zim_jik"}
};

TestItem [] test_items1 = {};
TestItem [] test_items2 = {};
TestItem [] test_items3 = {};

TestItem swap_words_in_test_item(TestItem item) {

string fntemp = item.fn1;
GrammarType gtemp = item.g1;

item.fn1 = item.fn2;
item.g1 = item.g2;
item.fn2 = fntemp;
item.g2 = gtemp;

return item;
}

/*
* prepares the testitems
*/
void prepare_test_stims(string[] correct, string[] incorrect) {
int[] first = {}; // Nope initializing with {1 ,1, ..., 0}; is an syntax error...
first.size = 9;
first[0] = 1;
first[1] = 1;
first[2] = 1;
first[3] = 1;
first[4] = 1;
first[5] = 0;
first[6] = 0;
first[7] = 0;
first[8] = 0;
first.shuffle(0, -1);
void prepare_test_stims(TestItem[] test_items) {
int[] swap = {}; // Nope initializing with {1 ,1, ..., 0}; is a syntax error...
swap.size = 9;
swap[0] = 1;
swap[1] = 1;
swap[2] = 1;
swap[3] = 1;
swap[4] = 1;
swap[5] = 0;
swap[6] = 0;
swap[7] = 0;
swap[8] = 0;
swap.shuffle(0, -1);

int first_stim = random(0, 2);
bool swap_if_one = random(0, 2) == 1;
int i = 0;
string stim_correct;
string stim_incorrect;
while (i < TOT_TEST_ITEMS) {
TestItem item;
item.id = i + 1;
item.test_type = first[i] == first_stim ? TRAINED_FIRST : FOREIGN_FIRST;
stim_correct = correct[i];
stim_incorrect = incorrect[i];

if (item.test_type == TRAINED_FIRST) {
item.fn1 = stim_correct;
item.fn2 = stim_incorrect;
}
else {
item.fn1 = stim_incorrect;
item.fn2 = stim_correct;
}
TestItem item = test_items[i];

if (swap_if_one)
if (swap[i] == 1)
item = swap_words_in_test_item(item);
else // swap if zero
if (swap[i] == 0)
item = swap_words_in_test_item(item);

if (i % 3 == 0)
append_test_item(test_items1, item);
Expand All @@ -447,21 +413,11 @@ void prepare_test_stims(string[] correct, string[] incorrect) {
void prepare_test_lists () {

// shuffle the order of the test items.
familiar_l1.shuffle(0,-1);
familiar_l2.shuffle(0,-1);
new_l1.shuffle(0,-1);
new_l2.shuffle(0,-1);

if (chosen_language == LANG_L1) {
if (chosen_test_stim == STIM_FAMILIAR)
prepare_test_stims(familiar_l1, familiar_l2);
else
prepare_test_stims(new_l1, new_l2);
}
else {
if (chosen_test_stim == STIM_FAMILIAR)
prepare_test_stims(familiar_l2, familiar_l1);
else
prepare_test_stims(new_l2, new_l1);
}
test_items_fam.shuffle(0,-1);
test_items_new.shuffle(0,-1);

if (chosen_test_stim == STIM_FAMILIAR)
prepare_test_stims(test_items_fam);
else
prepare_test_stims(test_items_new);
}
14 changes: 11 additions & 3 deletions nad_entrophy/test/test_page.zm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import colors;

Page train_page
{
TrainItem item; // trial control parameters
TrainItem item; // trial control parameters
int ntrials;


Expand Down Expand Up @@ -379,8 +379,16 @@ Page test_page
value = val;
ignore_remaining_hits();
rt = int(reaction_time(0));
if (item.test_type == TRAINED_FIRST && value == FIRST ||
item.test_type == FOREIGN_FIRST && value == SECOND)
GrammarType selected_grammar;
if (val == FIRST)
selected_grammar = item.g1;
else if (val == SECOND)
selected_grammar = item.g2;
else
print_error("Unexpected answer chosen, report this error\n");

if (chosen_language == LANG_L1 && selected_grammar == GRAM_L1 ||
chosen_language == LANG_L2 && selected_grammar == GRAM_L2)
correct = 1;
else
correct = 0;
Expand Down

0 comments on commit 774a96f

Please sign in to comment.