Update app.py
Browse files
app.py
CHANGED
|
@@ -122,9 +122,12 @@ def infer_and_log(text_input):
|
|
| 122 |
print(f"Uploaded log {submission_id}")
|
| 123 |
except Exception as e:
|
| 124 |
print(f"Error uploading log: {e}")
|
| 125 |
-
tokens = text_input.split()
|
|
|
|
|
|
|
| 126 |
|
| 127 |
-
formatted_output = " ".join(f'<span style=
|
|
|
|
| 128 |
return formatted_output, word_probs
|
| 129 |
|
| 130 |
def clear_fields():
|
|
|
|
| 122 |
print(f"Uploaded log {submission_id}")
|
| 123 |
except Exception as e:
|
| 124 |
print(f"Error uploading log: {e}")
|
| 125 |
+
# tokens = text_input.split()
|
| 126 |
+
# Replace \n with <br> in the input text for HTML rendering
|
| 127 |
+
tokens = text_input.replace("\n", " \n ").split()
|
| 128 |
|
| 129 |
+
formatted_output = " ".join(f'<span style="color:{color}">{token}</span>' if token != "\n" else "<br>" for token, color in zip(tokens, word_colors))
|
| 130 |
+
# formatted_output = " ".join(f'<span style= "color:{color}">{token}</span>' for token, color in zip(tokens, word_colors))
|
| 131 |
return formatted_output, word_probs
|
| 132 |
|
| 133 |
def clear_fields():
|