winglian commited on
Commit
792c165
1 Parent(s): 0f0c4f0

fix parsing so spaces in front of numbers don't go missing

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -189,13 +189,11 @@ def token_generator(generator1, generator2, mapping_fn=None, fillvalue=None):
189
  if not mapping_fn:
190
  mapping_fn = lambda x: x
191
  for output1, output2 in itertools.zip_longest(generator1, generator2, fillvalue=fillvalue):
192
- tokens1 = re.findall(r'\s*\S+\s*', mapping_fn(output1))
193
- tokens2 = re.findall(r'\s*\S+\s*', mapping_fn(output2))
194
- # tokens1 = re.findall(r'(.*?)(\s|$)', mapping_fn(output1))
195
- # tokens2 = re.findall(r'(.*?)(\s|$)', mapping_fn(output2))
196
 
197
  for token1, token2 in itertools.zip_longest(tokens1, tokens2, fillvalue=''):
198
- yield token1, token2
199
 
200
 
201
  def chat(history1, history2, system_msg, state):
 
189
  if not mapping_fn:
190
  mapping_fn = lambda x: x
191
  for output1, output2 in itertools.zip_longest(generator1, generator2, fillvalue=fillvalue):
192
+ tokens1 = re.findall(r'(.*?)(\s|$)', mapping_fn(output1))
193
+ tokens2 = re.findall(r'(.*?)(\s|$)', mapping_fn(output2))
 
 
194
 
195
  for token1, token2 in itertools.zip_longest(tokens1, tokens2, fillvalue=''):
196
+ yield "".join(token1), "".join(token2)
197
 
198
 
199
  def chat(history1, history2, system_msg, state):