Update handler.py
Browse files- handler.py +7 -7
handler.py
CHANGED
@@ -54,13 +54,13 @@ class EndpointHandler():
|
|
54 |
for result_indices in indices_array:
|
55 |
text = self.tokenizer.decode(input_ids[result_indices[0]:result_indices[-1]])
|
56 |
indices = [offset_mapping[result_indices[0]][0], offset_mapping[result_indices[-1]][1]]
|
57 |
-
|
58 |
-
|
59 |
-
text
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
result_array.append({'text': text, 'indices': indices})
|
65 |
return result_array
|
66 |
|
|
|
54 |
for result_indices in indices_array:
|
55 |
text = self.tokenizer.decode(input_ids[result_indices[0]:result_indices[-1]])
|
56 |
indices = [offset_mapping[result_indices[0]][0], offset_mapping[result_indices[-1]][1]]
|
57 |
+
if text != "" and not text.isspace():
|
58 |
+
while True:
|
59 |
+
if text[0] == " ":
|
60 |
+
text = text[1:]
|
61 |
+
indices[0] += 1
|
62 |
+
else:
|
63 |
+
break
|
64 |
result_array.append({'text': text, 'indices': indices})
|
65 |
return result_array
|
66 |
|