mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-04-24 23:56:21 +02:00
Fix list_index variable shadowing in fix_incorrect_toc
The loop variable `list_index = page_index - start_index` was overwriting the outer `list_index = incorrect_item['list_index']`, causing results to be written back to wrong index positions. Rename the loop variable to `page_list_idx` to avoid shadowing. Closes #66
This commit is contained in:
parent
599d2ce497
commit
85f17f9955
1 changed files with 3 additions and 3 deletions
|
|
@ -807,9 +807,9 @@ async def fix_incorrect_toc(toc_with_page_number, page_list, incorrect_results,
|
||||||
page_contents=[]
|
page_contents=[]
|
||||||
for page_index in range(prev_correct, next_correct+1):
|
for page_index in range(prev_correct, next_correct+1):
|
||||||
# Add bounds checking to prevent IndexError
|
# Add bounds checking to prevent IndexError
|
||||||
list_index = page_index - start_index
|
page_list_idx = page_index - start_index
|
||||||
if list_index >= 0 and list_index < len(page_list):
|
if page_list_idx >= 0 and page_list_idx < len(page_list):
|
||||||
page_text = f"<physical_index_{page_index}>\n{page_list[list_index][0]}\n<physical_index_{page_index}>\n\n"
|
page_text = f"<physical_index_{page_index}>\n{page_list[page_list_idx][0]}\n<physical_index_{page_index}>\n\n"
|
||||||
page_contents.append(page_text)
|
page_contents.append(page_text)
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue