abnerguzman commited on
Commit
7b11578
1 Parent(s): 1f71a40

Update demo.py

Browse files
Files changed (1) hide show
  1. demo.py +5 -3
demo.py CHANGED
@@ -480,18 +480,20 @@ def format_chunk_texts_for_display2(url, cid_ctext_tuples):
480
  print(f"cid={cid_ctext_tuple[0]}:")
481
  print(f"```{ctext}```")
482
 
483
- needs_ellipsis = False
484
  if j < n_chunks-1 and ids_l[j] != ids_l[j+1]:
485
  needs_ellipsis = True
486
  if len(ctext) > 512:
487
- # first_quote_idx = ctext.find(quote_start)
488
- first_quote_idx = -1
489
  for pidx, quote_pattern in enumerate(quote_pattern_l):
490
  match = re.search(quote_pattern, ctext)
491
  if match:
492
  print(f"pidx={pidx} found match: {match}")
493
  first_quote_idx = match.span()[0]
494
  break
 
 
495
 
496
  if first_quote_idx >= 0:
497
  ctext = ctext[first_quote_idx:]
 
480
  print(f"cid={cid_ctext_tuple[0]}:")
481
  print(f"```{ctext}```")
482
 
483
+ first_quote_idx, needs_ellipsis = -1, False
484
  if j < n_chunks-1 and ids_l[j] != ids_l[j+1]:
485
  needs_ellipsis = True
486
  if len(ctext) > 512:
487
+ _first_quote_idx = ctext.find(quote_start) # TODO: remove with better set of regex
488
+ print(f"_first_quote_idx={_first_quote_idx}")
489
  for pidx, quote_pattern in enumerate(quote_pattern_l):
490
  match = re.search(quote_pattern, ctext)
491
  if match:
492
  print(f"pidx={pidx} found match: {match}")
493
  first_quote_idx = match.span()[0]
494
  break
495
+ first_quote_idx = min(first_quote_idx, _first_quote_idx)
496
+ print(f"first_quote_idx={first_quote_idx}")
497
 
498
  if first_quote_idx >= 0:
499
  ctext = ctext[first_quote_idx:]