Update app.py
Browse files
app.py
CHANGED
@@ -90,20 +90,20 @@ def process_text(inputs: str, confidence_threshold: float):
|
|
90 |
if last_end < subtoken_start:
|
91 |
reconstructed_text += chunk[last_end:subtoken_start]
|
92 |
if word_data['prediction'] == 1:
|
93 |
-
reconstructed_text += f"<span style='background-color: rgba(0, 255, 0); display: inline;'>{subtoken_text}</span>"
|
94 |
else:
|
95 |
-
reconstructed_text += subtoken_text
|
96 |
last_end = subtoken_end
|
97 |
|
98 |
-
df_data['Word'].append(subtoken_text)
|
99 |
df_data['Prediction'].append(word_data['prediction'])
|
100 |
-
df_data['Confidence'].append(
|
101 |
df_data['Start'].append(subtoken_start + original_position_offset)
|
102 |
df_data['End'].append(subtoken_end + original_position_offset)
|
103 |
|
104 |
original_position_offset += len(chunk) + 1
|
105 |
|
106 |
-
reconstructed_text += chunk[last_end:]
|
107 |
|
108 |
df_tokens = pd.DataFrame(df_data)
|
109 |
return reconstructed_text, df_tokens
|
|
|
90 |
if last_end < subtoken_start:
|
91 |
reconstructed_text += chunk[last_end:subtoken_start]
|
92 |
if word_data['prediction'] == 1:
|
93 |
+
reconstructed_text += f"<span style='background-color: rgba(0, 255, 0); display: inline;'>{subtoken_text.replace('$', '\\$')}</span>"
|
94 |
else:
|
95 |
+
reconstructed_text += subtoken_text.replace('$', '\\$')
|
96 |
last_end = subtoken_end
|
97 |
|
98 |
+
df_data['Word'].append(subtoken_text.replace('$', '\\$'))
|
99 |
df_data['Prediction'].append(word_data['prediction'])
|
100 |
+
df_data['Confidence'].append(word_info[word_start]['confidence'])
|
101 |
df_data['Start'].append(subtoken_start + original_position_offset)
|
102 |
df_data['End'].append(subtoken_end + original_position_offset)
|
103 |
|
104 |
original_position_offset += len(chunk) + 1
|
105 |
|
106 |
+
reconstructed_text += chunk[last_end:].replace('$', '\\$')
|
107 |
|
108 |
df_tokens = pd.DataFrame(df_data)
|
109 |
return reconstructed_text, df_tokens
|