ejschwartz commited on
Commit
784e69f
·
1 Parent(s): 3782fc1
Files changed (1) hide show
  1. dist.py +5 -2
dist.py CHANGED
@@ -137,6 +137,9 @@ def explain_match(str1, str2, dp, wildcard_offsets_str1, wildcard_offsets_str2):
137
 
138
  return operations
139
 
 
 
 
140
  def print_match_summary(str1, str2, wildcard_offsets_str1=None, wildcard_offsets_str2=None):
141
  """
142
  Prints a summary of the match between two strings, highlighting wildcards by their offsets.
@@ -196,7 +199,7 @@ def print_match_summary(str1, str2, wildcard_offsets_str1=None, wildcard_offsets
196
  i += 1
197
  j += 1
198
  elif "Insertion:" in op:
199
- aligned_str1 += "-"
200
 
201
  aligned_str2 += str2[j:j+1]
202
 
@@ -205,7 +208,7 @@ def print_match_summary(str1, str2, wildcard_offsets_str1=None, wildcard_offsets
205
  elif "Deletion:" in op:
206
  aligned_str1 += str1[i:i+1]
207
 
208
- aligned_str2 += "-"
209
  match_indicators += " "
210
  i += 1
211
 
 
137
 
138
  return operations
139
 
140
+ def to_bytes(s):
141
+ return s.encode('utf-8') if isinstance(s, str) else s
142
+
143
  def print_match_summary(str1, str2, wildcard_offsets_str1=None, wildcard_offsets_str2=None):
144
  """
145
  Prints a summary of the match between two strings, highlighting wildcards by their offsets.
 
199
  i += 1
200
  j += 1
201
  elif "Insertion:" in op:
202
+ aligned_str1 += to_bytes("-")
203
 
204
  aligned_str2 += str2[j:j+1]
205
 
 
208
  elif "Deletion:" in op:
209
  aligned_str1 += str1[i:i+1]
210
 
211
+ aligned_str2 += to_bytes("-")
212
  match_indicators += " "
213
  i += 1
214