Skip to content

Commit 010fe03

Browse files
committed
Update text chunker
1 parent f56390a commit 010fe03

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

adi_function_app/semantic_text_chunker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,18 @@ def retrieve_current_chunk():
232232

233233
# Detect if table or figure
234234
if is_table_or_figure_map[current_sentence_index]:
235-
new_is_table_or_figure_map.append(True)
236235
if forwards_direction:
237236
if len(current_chunk) > 0:
238237
current_chunk.append(current_sentence)
239238
chunks.append(retrieve_current_chunk())
239+
new_is_table_or_figure_map.append(True)
240240
current_chunk = []
241241
else:
242242
current_chunk.append(current_sentence)
243243
else:
244244
# On the backwards pass we don't want to add to the table chunk
245245
chunks.append(retrieve_current_chunk())
246+
new_is_table_or_figure_map.append(True)
246247
current_chunk.append(current_sentence)
247248

248249
index += 1
@@ -262,16 +263,18 @@ def retrieve_current_chunk():
262263
# Finish off
263264
current_chunk.append(current_sentence)
264265
chunks.append(retrieve_current_chunk())
266+
new_is_table_or_figure_map.append(False)
265267
current_chunk = []
266268

267269
index += 1
268270
continue
269271
elif is_table_or_figure_ahead:
270272
# Add to the ahead chunk
271273
chunks.append(retrieve_current_chunk())
274+
new_is_table_or_figure_map.append(False)
272275
if forwards_direction:
273276
current_chunk = sentences[
274-
current_sentence_index : current_sentence
277+
current_sentence_index : current_sentence_index
275278
+ min_of_distance_to_next_figure_or_num_surrounding_sentences
276279
]
277280
else:

0 commit comments

Comments
 (0)