Update app.py
Browse files
app.py
CHANGED
|
@@ -179,34 +179,34 @@ def colorize_text(text, colors=None, background_color=None):
|
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
-
def colorize_text(text):
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
|
| 211 |
def colorize_and_update(system_message, submit_update):
|
| 212 |
colorized_system_message = colorize_text(system_message['content'])
|
|
|
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
+
# def colorize_text(text):
|
| 183 |
+
# colorized_text = ""
|
| 184 |
+
# lines = text.split("\n")
|
| 185 |
+
|
| 186 |
+
# for line in lines:
|
| 187 |
+
# doc = nlp(line)
|
| 188 |
+
# for token in doc:
|
| 189 |
+
# if token.ent_type_:
|
| 190 |
+
# colorized_text += f'**{token.text_with_ws}**'
|
| 191 |
+
# elif token.pos_ == 'NOUN':
|
| 192 |
+
# colorized_text += f'<span style="color: #FF3300; background-color: transparent;">{token.text_with_ws}</span>'
|
| 193 |
+
# elif token.pos_ == 'VERB':
|
| 194 |
+
# colorized_text += f'<span style="color: #FFFF00; background-color: transparent;">{token.text_with_ws}</span>'
|
| 195 |
+
# elif token.pos_ == 'ADJ':
|
| 196 |
+
# colorized_text += f'<span style="color: #00CC00; background-color: transparent;">{token.text_with_ws}</span>'
|
| 197 |
+
# elif token.pos_ == 'ADV':
|
| 198 |
+
# colorized_text += f'<span style="color: #FF6600; background-color: transparent;">{token.text_with_ws}</span>'
|
| 199 |
+
# elif token.is_digit:
|
| 200 |
+
# colorized_text += f'<span style="color: #9900CC; background-color: transparent;">{token.text_with_ws}</span>'
|
| 201 |
+
# elif token.is_punct:
|
| 202 |
+
# colorized_text += f'<span style="color: #8B4513; background-color: transparent;">{token.text_with_ws}</span>'
|
| 203 |
+
# elif token.is_quote:
|
| 204 |
+
# colorized_text += f'<span style="color: #008080; background-color: transparent;">{token.text_with_ws}</span>'
|
| 205 |
+
# else:
|
| 206 |
+
# colorized_text += token.text_with_ws
|
| 207 |
+
# colorized_text += "<br>"
|
| 208 |
+
|
| 209 |
+
# return colorized_text
|
| 210 |
|
| 211 |
def colorize_and_update(system_message, submit_update):
|
| 212 |
colorized_system_message = colorize_text(system_message['content'])
|