lucalp commited on
Commit
295e2d6
·
1 Parent(s): 5e19880

Underscore only sole space patches

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -321,11 +321,12 @@ class BytelatentProcessor:
321
 
322
  # Create highlighted text data
323
  _highlighted_data, patch_count = self._create_highlight_data(patch_lengths, tokens)
324
- ind_highlighted_data = [(text.replace(" -1", "_-1").replace("-1", ""), label) for text, label in _highlighted_data]
325
  grouped_data = defaultdict(str)
326
  for text, label in ind_highlighted_data:
327
  grouped_data[label] += text
328
- highlighted_data = [(text, label) for label, text in grouped_data.items()]
 
329
 
330
  # Create plot
331
  fig = None
 
321
 
322
  # Create highlighted text data
323
  _highlighted_data, patch_count = self._create_highlight_data(patch_lengths, tokens)
324
+ ind_highlighted_data = [(text.replace("-1", ""), label) for text, label in _highlighted_data]
325
  grouped_data = defaultdict(str)
326
  for text, label in ind_highlighted_data:
327
  grouped_data[label] += text
328
+ underscore_sole_space_patch = lambda text: text.replace(" ", "_") if text == " " else text
329
+ highlighted_data = [(underscore_sole_space_patch(text), label) for label, text in grouped_data.items()]
330
 
331
  # Create plot
332
  fig = None