forked from marisacasillas/chattr-basic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-chattr-info.R
162 lines (146 loc) · 7.1 KB
/
fetch-chattr-info.R
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Default argument values
default.max.gap <- 2000 # allows up to this number of milliseconds of gap at transitions
default.max.overlap <- 1000 # allows up to this number of milliseconds of overlap at transitions
default.min.utt.dur <- 0 # assesses all utterances, regardless of duration
default.mode <- "strict" # uses strict mode when choosing between multiple transition types
default.interactants <- FALSE # all speaker tiers as interactants
default.addressee.tags <- FALSE # all utterances assessed, regardless of addressee
default.lxonly <- FALSE # all utterances assessed, regardless of linguistic content
default.cliptier <- ".alloneclip" # all utterances in the file are considered
default.output <- "intseqtbl" # returns intseq data in addition to basic turn taking data
default.n.runs <- 0 # returns no random runs by default (b/c they are time consuming)
# NOTE:
# If something isn't set to a default below, it means the argument value is
# specific to that instance of the function call, e.g., file path, or
# specific to that fetch_chatter call, e.g., the nearonly val for LENA .its
# files and the specific target.ptcp settings for LENA and AAS files)
fetch_chattr_tttbl <- function(
# requires user input:
spchtbl, target.ptcp,
# in case of independent tttbl processing with this function:
cliptier = default.cliptier, lxonly = default.lxonly,
# used by fetch_transitions() and fetch_intseqs() below:
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = default.min.utt.dur, interactants = default.interactants,
addressee.tags = default.addressee.tags, mode = default.mode,
# fetch_randomruns() arguments used below:
output = default.output, n.runs = default.n.runs) {
# TO DO: modify input spchtbl to be in line with cliptier and lxonly args if needed
# get tttbl and/or intseq data as desired
if (output == "intseqtbl" | output == "tttbl") {
print("Estimating turn transitions...")
real.tbl <- fetch_transitions(spchtbl, allowed.gap, allowed.overlap,
min.utt.dur, target.ptcp, interactants,
addressee.tags, mode)
if (output == "intseqtbl" & nrow(real.tbl) > 1) {
print("Estimating interactional sequences...")
real.tbl <- fetch_intseqs(real.tbl, allowed.gap)
}
if (n.runs > 0) {
print("Estimating interactional sequences for randomized simulations...")
all.tbls <- fetch_randomruns(
spchtbl = spchtbl, n.runs = n.runs,
allowed.gap = allowed.gap, allowed.overlap = allowed.overlap,
min.utt.dur = min.utt.dur, target.ptcp = target.ptcp,
interactants = interactants, addressee.tags = addressee.tags,
mode = mode, output = output, input.tbl = real.tbl,
return.real = TRUE)
} else {
all.tbls <- list(
real.tt.vals = real.tbl,
random.tt.vals = NA)
}
# return the results as a list of the real and random tables
return(all.tbls)
} else {
print("Invalid type of output specified: the options are 'intseqtbl' (default) or 'tttbl'.")
}
}
run_chatter_pipeline <- function(
tbl, tbltype, target.ptcp, addressee.tags, cliptier, nearonly,
lxonly = default.lxonly,
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = default.min.utt.dur, interactants = default.interactants,
mode = default.mode, output = default.output, n.runs = default.n.runs) {
# step 1. read in the file
spchtbl <- read_spchtbl(filepath = tbl, tbltype = tbltype,
cliptier = cliptier,
lxonly = lxonly, nearonly = nearonly)
# step 2. run the speech annotations through the tt behavior detection pipeline
ttinfotbls <- fetch_chattr_tttbl(
spchtbl = spchtbl, target.ptcp = target.ptcp,
cliptier = cliptier, lxonly = lxonly,
allowed.gap = allowed.gap, allowed.overlap = allowed.overlap,
min.utt.dur = min.utt.dur, interactants = interactants,
addressee.tags = addressee.tags,
mode = mode, output = output, n.runs = n.runs)
# step 3. create a summary of the tt behavior by clip and overall, incl. the random baseline
ttinfotbls$tt.summary <- summarize_chattr(ttinfotbls)
return(ttinfotbls)
}
fetch_chatter_LENA <- function(
# read_spchtbl() arguments
tbl, tbltype = "lena-its",
cliptier = default.cliptier, lxonly = default.lxonly, nearonly = FALSE,
# fetch_transitions() and fetch_intseqs() arguments
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = 599,
target.ptcp = "CH", interactants = default.interactants,
addressee.tags = default.addressee.tags, mode = default.mode,
# estimate_baseline() arguments
output = default.output, n.runs = default.n.runs) {
ttinfotbls <- run_chatter_pipeline(
tbl, tbltype, target.ptcp, addressee.tags, cliptier, nearonly,
lxonly, allowed.gap, allowed.overlap, min.utt.dur, interactants,
mode, output, n.runs)
return(ttinfotbls)
}
fetch_chatter_AAS <- function(
# read_spchtbl() arguments
tbl, tbltype = "aas-elan-txt",
cliptier = "code", lxonly = default.lxonly, nearonly = FALSE,
# fetch_transitions() and fetch_intseqs() arguments
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = default.min.utt.dur,
target.ptcp = "CHI", interactants = default.interactants,
addressee.tags = "[CT]", mode = default.mode,
# estimate_baseline() arguments
output = default.output, n.runs = default.n.runs) {
ttinfotbls <- run_chatter_pipeline(
tbl, tbltype, target.ptcp, addressee.tags, cliptier, nearonly,
lxonly, allowed.gap, allowed.overlap, min.utt.dur, interactants,
mode, output, n.runs)
return(ttinfotbls)
}
fetch_chatter_BST <- function(
# read_spchtbl() arguments
tbl, target.ptcp, tbltype = "basic-speech-tbl",
cliptier = default.cliptier, lxonly = default.lxonly, nearonly = FALSE,
# fetch_transitions() and fetch_intseqs() arguments
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = default.min.utt.dur, interactants = default.interactants,
addressee.tags = default.addressee.tags, mode = default.mode,
# estimate_baseline() arguments
output = default.output, n.runs = default.n.runs) {
ttinfotbls <- run_chatter_pipeline(
tbl, tbltype, target.ptcp, addressee.tags, cliptier, nearonly,
lxonly, allowed.gap, allowed.overlap, min.utt.dur, interactants,
mode, output, n.runs)
return(ttinfotbls)
}
fetch_chatter_RTTM <- function(
# read_spchtbl() arguments
tbl, target.ptcp, tbltype = "rttm",
cliptier = default.cliptier, lxonly = default.lxonly, nearonly = FALSE,
# fetch_transitions() and fetch_intseqs() arguments
allowed.gap = default.max.gap, allowed.overlap = default.max.overlap,
min.utt.dur = default.min.utt.dur, interactants = default.interactants,
addressee.tags = default.addressee.tags, mode = default.mode,
# estimate_baseline() arguments
output = default.output, n.runs = default.n.runs) {
ttinfotbls <- run_chatter_pipeline(
tbl, tbltype, target.ptcp, addressee.tags, cliptier, nearonly,
lxonly, allowed.gap, allowed.overlap, min.utt.dur, interactants,
mode, output, n.runs)
return(ttinfotbls)
}