Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions run_pageindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
help='Minimum token threshold for thinning (markdown only)')
parser.add_argument('--summary-token-threshold', type=int, default=200,
help='Token threshold for generating summaries (markdown only)')
parser.add_argument('--output-dir',type=str,default='./results',
help='Directory to save output JSON')
args = parser.parse_args()

# Validate that exactly one file type is specified
Expand Down Expand Up @@ -70,8 +72,8 @@

# Save results
pdf_name = os.path.splitext(os.path.basename(args.pdf_path))[0]
output_dir = './results'
output_file = f'{output_dir}/{pdf_name}_structure.json'
output_dir = args.output_dir
output_file = os.path.join(output_dir, f'{pdf_name}_structure.json')
os.makedirs(output_dir, exist_ok=True)

with open(output_file, 'w', encoding='utf-8') as f:
Expand Down Expand Up @@ -124,11 +126,11 @@

# Save results
md_name = os.path.splitext(os.path.basename(args.md_path))[0]
output_dir = './results'
output_file = f'{output_dir}/{md_name}_structure.json'
output_dir = args.output_dir
output_file = os.path.join(output_dir, f'{pdf_name}_structure.json')
os.makedirs(output_dir, exist_ok=True)

with open(output_file, 'w', encoding='utf-8') as f:
json.dump(toc_with_page_number, f, indent=2, ensure_ascii=False)

print(f'Tree structure saved to: {output_file}')
print(f'Tree structure saved to: {output_file}')