|
|
import re |
|
|
|
|
|
|
|
|
css = """ |
|
|
.scrollable-table { |
|
|
max-height: 300px; |
|
|
overflow-y: auto; |
|
|
border: 1px solid #ccc; |
|
|
padding: 10px; |
|
|
|
|
|
} |
|
|
.scrollable-table table { |
|
|
width: 100%; |
|
|
border-collapse: collapse; |
|
|
background-color: #FFFFFF; |
|
|
|
|
|
} |
|
|
.scrollable-table th, .scrollable-table td { |
|
|
border: 1px solid #ddd; |
|
|
padding: 8px; |
|
|
text-align: left; |
|
|
color: #000000 |
|
|
|
|
|
} |
|
|
.scrollable-table th { |
|
|
background-color: #EAF2FF; |
|
|
color: #3366CC; |
|
|
} |
|
|
""" |
|
|
|
|
|
def parse_transcript(transcript): |
|
|
|
|
|
pattern = re.compile(r'(\d{2}:\d{2})\s+(.+?)(?=\d{2}:\d{2}|$)', re.DOTALL) |
|
|
matches = pattern.findall(transcript) |
|
|
|
|
|
timestamps = [] |
|
|
texts = [] |
|
|
|
|
|
for match in matches: |
|
|
timestamps.append(match[0]) |
|
|
texts.append(match[1].strip()) |
|
|
|
|
|
return timestamps, texts |
|
|
|
|
|
def create_transcript_table(timestamps, transcript_text): |
|
|
table_html = '<div class="scrollable-table">\n' |
|
|
table_html += '<table>\n' |
|
|
table_html += ' <thead>\n' |
|
|
table_html += ' <tr>\n' |
|
|
table_html += ' <th>Timestamp</th>\n' |
|
|
table_html += ' <th>Transcript</th>\n' |
|
|
table_html += ' </tr>\n' |
|
|
table_html += ' </thead>\n' |
|
|
table_html += ' <tbody>\n' |
|
|
for ts, text in zip(timestamps, transcript_text): |
|
|
table_html += ' <tr>\n' |
|
|
table_html += f' <td>{ts}</td>\n' |
|
|
table_html += f' <td>{text}</td>\n' |
|
|
table_html += ' </tr>\n' |
|
|
table_html += ' </tbody>\n' |
|
|
table_html += '</table>\n' |
|
|
return table_html |
|
|
|
|
|
def filter_transcript(): |
|
|
timestamps = [ |
|
|
"15.0 - 17.0", |
|
|
"38.08 - 39.50" |
|
|
] |
|
|
transcript_text = [ |
|
|
"Sad (prompt; 1st)", |
|
|
"Because he fell (no prompt; 2nd)" |
|
|
] |
|
|
return timestamps, transcript_text |
|
|
|
|
|
|
|
|
def generate_guidance(): |
|
|
guidance_text = """ Engagement: Student may display behaviors such as rocking when showing engagement. |
|
|
Impact factors: Weather (e.g., raining) can impact student’s performance.""" |
|
|
return guidance_text |