36 self.
id = Utterance.next_id
38 Utterance.next_id += 1
45 output = BLLObject.__str__(self, [
'next',
'prev',
'seg'])
47 output +=
'-seg: %s\n' % (self.seg.num)
50 output +=
'-next: %s\n' % (str(self.next.id)
if self.
next else 'None')
51 output +=
'-prev: %s\n' % (str(self.prev.id)
if self.
prev else 'None')
63 while is_linkable
and i < len(self.seg.speakers):
66 is_linkable = self.seg.speakers[i].speaker_codeinfo.is_linkable
70 notes_opt = DBConstants.LENA_NOTES_CODES.get_option(self.
lena_notes)
71 if is_linkable
and notes_opt !=
None and not self.
trans_phrase:
72 is_linkable = notes_opt.is_linkable
93 self.trans_phrase.replace(
'<',
'<').replace(
'>',
'>')
94 bad_chars = re.findall(
'[^A-Za-z\'\"<>\s\^]', self.
trans_phrase)
96 bad_chars = dict(zip(bad_chars, [
True] * len(bad_chars))).keys()
99 bad_chars_str = reduce(
lambda accum, c:
'%s, "%c"' % (accum, c),
101 '"%c"' % (bad_chars[0]))
102 error_collector.add(
ParserError(
'Transcription phrase contains the following invalid characters: %s' % (bad_chars_str), self))
105 if self.
start ==
None:
106 error_collector.add(
ParserError(
'Parser was unable to determine utterance start time.', self))
108 error_collector.add(
ParserError(
'Parser was unable to determine utterance end time.', self))
110 if DBConstants.LENA_NOTES_CODES.get_option(self.
lena_notes) ==
None:
111 error_collector.add(
ParserError(
'Unrecognized LENA note.', self))
115 if len(self.
trans_codes) < len(DBConstants.TRANS_CODES):
116 error_collector.add(
ParserError(
'Utterance has less than %d transcriber codes.' % (len(DBConstants.TRANS_CODES)), self))
122 error_msgs = DBConstants.TRANS_CODES[i].is_valid(self.
trans_codes[i])
124 bad_indices.append({
'index': i + 1,
'error_msgs': error_msgs})
127 err_str =
'Utterance transcriber codes contain the following errors:\n'
128 for issue
in bad_indices:
129 err_str +=
' Code %d:\n' % (issue[
'index'])
130 for msg
in issue[
'error_msgs']:
131 err_str +=
' -%s\n' % (msg)