18 if not filename.lower().endswith(
'.csv'):
23 self.
logger = logging.getLogger(__name__)
34 csv_writer = csv.writer(csv_file)
35 csv_writer.writerow([
'Check name: "%s"' % (self.check.name)])
36 csv_writer.writerow([
'Last run on %s' % (UIUtils.get_db_timestamp_str(str(self.check.last_run)))])
37 csv_writer.writerow([
'Created on %s' % (UIUtils.get_db_timestamp_str(str(self.check.created)))])
38 csv_writer.writerow([
'TRS / CSV file: %s' % (self.check.input_filename)])
39 csv_writer.writerow([
'WAV file: %s' % (self.check.wav_filename)])
40 csv_writer.writerow([
'Number of Segs: %s' % (self.check.num_segs)])
41 csv_writer.writerow([
'Default context padding (sec): %s' % (self.check.default_context_padding)])
42 csv_writer.writerow([
'Randomly Pick Segments: %s' % (str(self.check.pick_randomly)) ])
45 if self.check.filters:
46 csv_writer.writerow([
'Filters:'])
47 for cur_filter
in self.check.filters:
48 csv_writer.writerow([cur_filter.get_filter_desc_str()])
50 csv_writer.writerow([
'Filters: None'])
53 csv_writer.writerow([])
54 headers = [
'Test Number',
'LENA Start Time (w/o padding)',
'LENA End Time (w/o padding)',
'Context Padding',
'User-Adjusted Start Time',
'User-Adjusted End Time',
'Uncertain/Other',
'Syllables (with context)',
'Syllables (w/o context)',
'Actual Codes',
'Category Selection',
'Category Correct']
55 csv_writer.writerow(headers)
60 for i
in range(self.check.num_segs):
61 cur_test = self.check.tests[i]
64 row.append(str(i + 1))
65 row.append(
'%0.3f' % (cur_test.seg.start))
66 row.append(
'%0.3f' % (cur_test.seg.end))
67 row.append(str(cur_test.context_padding))
68 row.append(
'%0.3f' % (cur_test.seg.user_adj_start))
69 row.append(
'%0.3f' % (cur_test.seg.user_adj_end))
70 row.append(str(bool(cur_test.is_uncertain)))
71 row.append(str(cur_test.syllables_w_context))
72 row.append(str(cur_test.syllables_wo_context)
if cur_test.syllables_wo_context !=
None else '')
76 for cur_codeinfo
in actual_codes:
77 codes_str += cur_codeinfo.code +
' '
78 if codes_str.endswith(
' '):
79 codes_str = codes_str[:-1]
83 row.append(cat_sel.disp_desc)
86 correct_count += int(cat_correct)
87 row.append(str(bool(cat_correct)))
89 csv_writer.writerow(row)
92 csv_writer.writerow([])
93 csv_writer.writerow([
'Ratio correct: %0.2f' % ( float(correct_count) / float(self.check.num_segs) )])
97 except Exception
as err:
98 self.logger.error(
'Error exporting check: %s' % (err))
103 return DBConstants.COMBOS[DBConstants.COMBO_GROUPS.RELIABILITY_CATEGORIES][test.category_input]
107 actual_code_rows = db.select(
'segs_to_speaker_codes rel join speaker_codes c on rel.speaker_code_id = c.id',
114 for cur_row
in actual_code_rows:
115 codes.append(DBConstants.SPEAKER_CODES.get_option(cur_row[0]))
129 while not result
and i < len(actual_codes):
130 result = test_fcn(actual_codes[i])
140 cats_enum = DBConstants.COMBO_OPTIONS[DBConstants.COMBO_GROUPS.RELIABILITY_CATEGORIES]
142 cats_enum.SILENCE:
lambda speaker_code: speaker_code.is_speaker_type(DBConstants.SPEAKER_TYPES.SILENCE),
144 cats_enum.OVERLAPPING_SPEECH:
lambda speaker_code: speaker_code.has_property(DBConstants.SPEAKER_PROPS.OVERLAPPING),
146 cats_enum.MEDIA:
lambda speaker_code: speaker_code.has_property(DBConstants.SPEAKER_PROPS.MEDIA),
148 cats_enum.TARGET_CHILD:
lambda speaker_code: speaker_code.is_speaker_type(DBConstants.SPEAKER_TYPES.TARGET_CHILD),
150 cats_enum.OTHER_CHILD:
lambda speaker_code: speaker_code.is_speaker_type(DBConstants.SPEAKER_TYPES.OTHER_CHILD),
152 cats_enum.FEMALE_ADULT:
lambda speaker_code: speaker_code.is_speaker_type(DBConstants.SPEAKER_TYPES.FEMALE_ADULT),
154 cats_enum.MALE_ADULT:
lambda speaker_code: speaker_code.is_speaker_type(DBConstants.SPEAKER_TYPES.MALE_ADULT),
156 cats_enum.DISTANT:
lambda speaker_code: speaker_code.is_distance(DBConstants.SPEAKER_DISTANCES.FAR),
158 cats_enum.NON_VERBAL_NOISE:
lambda speaker_code: speaker_code.has_property(DBConstants.SPEAKER_PROPS.NON_VERBAL_NOISE),
160 cats_enum.FUZ:
lambda speaker_code: speaker_code.code == DBConstants.SPEAKER_CODES.get_option(
'FUZ').code,
165 validate_fcns[cat_sel.db_id],