pszemraj commited on
Commit
665f924
1 Parent(s): b40e029

🚸 provide details on truncation

Browse files

Signed-off-by: peter szemraj <[email protected]>

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import contextlib
2
  import logging
 
3
  import time
4
  from pathlib import Path
5
 
@@ -68,7 +69,14 @@ def proc_submission(
68
 
69
  if processed["was_truncated"]:
70
  tr_in = processed["truncated_text"]
71
- msg = f"Input text was truncated to {max_input_length} words (based on whitespace)"
 
 
 
 
 
 
 
72
  logging.warning(msg)
73
  history["WARNING"] = msg
74
  else:
 
1
  import contextlib
2
  import logging
3
+ import re
4
  import time
5
  from pathlib import Path
6
 
 
69
 
70
  if processed["was_truncated"]:
71
  tr_in = processed["truncated_text"]
72
+ # create elaborate HTML warning
73
+ input_wc = re.split(r"\s+", input_text)
74
+ msg = f"""
75
+ <div style="background-color: #f44336; color: white; padding: 20px;">
76
+ <h3>Warning</h3>
77
+ <p>Input text was truncated to {max_input_length} words. This is about {100*max_input_length/len(input_wc):.2f}% of the submission.</p>
78
+ </div>
79
+ """
80
  logging.warning(msg)
81
  history["WARNING"] = msg
82
  else: