forked from PhPeKe/OB1_SAM
-
Notifications
You must be signed in to change notification settings - Fork 3
/
boundary_task.py
59 lines (47 loc) · 2.3 KB
/
boundary_task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# __author__ = 'Sam van Leipsig'
from __future__ import division
import pandas as pd
import numpy as np
from boundary_task_functions import *
import os
## Three conditions: Repeated, control, baseline
## Select sentences with where two words of same length are repeated (Stimulus size, 5 words)
## Select a control word from the text that doesn't contain any of the letters of the first word
## Save the word condition in seperate variable
## Apply these sentences during reading
## Create the text
## Select two random filler sentences
## Select sentence with repeat,control or baseline version
## No same condition sequentially, at least one other condition in between.
## do each condition at least twice for each test sentence
## original word position, new word position, condition
filename = "PSC_ALL"
filepath_psc = "PSC/" + filename + ".txt"
BT_filename = 'Data/boundary_task_DF.pkl'
def create_boundary_task(filepath_psc):
##PARAMETERS
length_selection = [4,5]
max_freq_diff = 1.0
max_pred = 0.43
condition_repeats = 3
## FIND CONDITION AND CONTROL
df_psc = create_df_psc(filepath_psc)
sentence_lenghts_list = parse_sentences(filepath_psc)
df_psc = add_sentence_numbers(df_psc, sentence_lenghts_list)
df_psc_selection = select_condition_words(df_psc, length_selection, max_freq_diff, max_pred)
df_psc = add_control_words(df_psc, df_psc_selection, length_selection, max_freq_diff)
#df_psc = remove_capitals(df_psc)
## MAKE BOUNDARY TASK PSC
condition_sentence_numbers = np.array(df_psc[df_psc['control indices']!=0]['sentence number'].values,dtype=int)
# for i in condition_sentence_numbers:
# print df_psc[(df_psc['sentence number']==i)]['words'].values, df_psc[(df_psc['sentence number']==i)]['control words'].values
# print df_psc[(df_psc['sentence number']==114)],condition_sentence_numbers
filler_sentencenumber_list = create_filler_sentences(df_psc,condition_sentence_numbers)
df_exp_psc = make_df_boundarytask(condition_sentence_numbers,filler_sentencenumber_list,df_psc,condition_repeats)
return df_exp_psc
def save_dataframe(df,df_filename):
df.to_pickle(df_filename)
def read_dataframe(df_filename):
return pd.read_pickle(df_filename)
create_boundary_task(filepath_psc)
save_dataframe(create_boundary_task(filepath_psc),BT_filename)