-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbatch_basic_level_recode.rb
More file actions
44 lines (32 loc) · 1.15 KB
/
batch_basic_level_recode.rb
File metadata and controls
44 lines (32 loc) · 1.15 KB
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
require 'Datavyu_API'
$input_dir = "~/code/work/bergelsonlab/pho_reliability_data/pho_checks_in_2"
$output_dir = "~/code/work/bergelsonlab/pho_reliability_data/orig_csv_output"
def basic_level(in_dir, file)
puts(file)
$db, $pj = load_db(File.join(in_dir, file))
col = get_column("child_labeled_object")
bl_out_path = File.join(File.expand_path($output_dir), file.sub(".opf", "_processed.csv"))
# col = getColumn(column)
if col.cells.length == 0
next
end
CSV.open(bl_out_path, "wb") do |csv|
csv << ["labeled_object.ordinal","labeled_object.onset",
"labeled_object.offset","labeled_object.object",
"labeled_object.utterance_type","labeled_object.object_present",
"labeled_object.speaker","basic_level"]
for cell in col.cells
csv << [cell.ordinal.to_s, cell.onset.to_s, cell.offset.to_s, cell.object.to_s,
cell.utterance_type.to_s, cell.object_present.to_s, cell.speaker.to_s, ""]
end
end
end
begin
in_dir = File.expand_path($input_dir)
filenames = Dir.new(in_dir).entries
for file in filenames
if file.end_with? ".opf"
basic_level(in_dir, file)
end
end
end