From 75fee007b5c4213aec8d10bc3f48a5a47313883f Mon Sep 17 00:00:00 2001 From: Akshat Kumar Sharma Date: Wed, 27 May 2026 12:37:31 +0530 Subject: [PATCH] Add --output-dir argument for custom JSON output path --- run_pageindex.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/run_pageindex.py b/run_pageindex.py index 673439d89..a03df2ee0 100644 --- a/run_pageindex.py +++ b/run_pageindex.py @@ -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 @@ -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: @@ -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}') \ No newline at end of file + print(f'Tree structure saved to: {output_file}')