Ashlee Kupor
commited on
Commit
·
8d19829
1
Parent(s):
a863bd3
Add in talk time
Browse files- handler.py +16 -0
handler.py
CHANGED
|
@@ -293,6 +293,17 @@ class EndpointHandler():
|
|
| 293 |
formatted.append({'speaker': utterance.speaker, 'data': utterance.text, 'time': utterance.starttime, 'chat': utterance.chat})
|
| 294 |
return sorted(formatted, key=lambda d: d['time'])
|
| 295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
def talk_moves_list_to_json(self, utterances: List[Utterance]) -> List[str]:
|
| 297 |
formatted = []
|
| 298 |
for utterance in utterances:
|
|
@@ -419,6 +430,11 @@ class EndpointHandler():
|
|
| 419 |
print("TALK MOVES FOUND")
|
| 420 |
print(utterance_talk_moves_json)
|
| 421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 422 |
print("TALK MOVE")
|
| 423 |
print(talk_move)
|
| 424 |
|
|
|
|
| 293 |
formatted.append({'speaker': utterance.speaker, 'data': utterance.text, 'time': utterance.starttime, 'chat': utterance.chat})
|
| 294 |
return sorted(formatted, key=lambda d: d['time'])
|
| 295 |
|
| 296 |
+
def get_talk_time(self, utterances: List[Utterance]) -> (float, float):
|
| 297 |
+
sl_time = 0
|
| 298 |
+
student_time = 0
|
| 299 |
+
for utterance in utterances:
|
| 300 |
+
if '(SL)' not in utterance.speaker:
|
| 301 |
+
student_time += utterance.endtime - utterance.starttime
|
| 302 |
+
else:
|
| 303 |
+
sl_time += utterance.endtime - utterance.starttime
|
| 304 |
+
total_time = sl_time + student_time
|
| 305 |
+
return sl_time / total_time, student_time / total_time
|
| 306 |
+
|
| 307 |
def talk_moves_list_to_json(self, utterances: List[Utterance]) -> List[str]:
|
| 308 |
formatted = []
|
| 309 |
for utterance in utterances:
|
|
|
|
| 430 |
print("TALK MOVES FOUND")
|
| 431 |
print(utterance_talk_moves_json)
|
| 432 |
|
| 433 |
+
sl_time, student_time = self.get_talk_time(full_transcript)
|
| 434 |
+
talk_time_json = json.dumps({'sl': sl_time, 'student': student_time}, separators=(',', ':'))
|
| 435 |
+
print("TALK TIME")
|
| 436 |
+
print(talk_time_json)
|
| 437 |
+
|
| 438 |
print("TALK MOVE")
|
| 439 |
print(talk_move)
|
| 440 |
|