content-extraction 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- content_extraction/file_handlers.py +1 -1
- content_extraction/process.py +59 -0
- {content_extraction-0.1.0.dist-info → content_extraction-0.2.0.dist-info}/METADATA +1 -1
- {content_extraction-0.1.0.dist-info → content_extraction-0.2.0.dist-info}/RECORD +6 -5
- {content_extraction-0.1.0.dist-info → content_extraction-0.2.0.dist-info}/WHEEL +0 -0
- {content_extraction-0.1.0.dist-info → content_extraction-0.2.0.dist-info}/top_level.txt +0 -0
@@ -50,7 +50,7 @@ def process_pdf(file_path: str, output_dir: str):
|
|
50
50
|
"""
|
51
51
|
logger.info(f'[Processing PDF file] started for: "{file_path}"')
|
52
52
|
# This path assumes the script is located at src/scripts/process_document.sh
|
53
|
-
script_path = os.path.join(os.path.dirname(__file__), '
|
53
|
+
script_path = os.path.join(os.path.dirname(__file__), 'process_document.sh')
|
54
54
|
output_html_path = os.path.join(output_dir, 'index.html') # Define output_html_path
|
55
55
|
logger.debug(f'[Processing PDF file] script path: "{script_path}"; output_html_path: "{output_html_path}"')
|
56
56
|
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import argparse
|
2
|
+
import sys
|
3
|
+
import logging
|
4
|
+
|
5
|
+
from content_extraction.logging_config import setup_logging
|
6
|
+
from content_extraction.file_handlers import process_file
|
7
|
+
|
8
|
+
|
9
|
+
logger = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
|
12
|
+
def main():
|
13
|
+
"""
|
14
|
+
Main function to process the input file/URL and generate structured output.
|
15
|
+
"""
|
16
|
+
setup_logging()
|
17
|
+
parser = argparse.ArgumentParser(
|
18
|
+
description='Process various document types (PDF, PPTX, DOCX, MD, HTML, URL) and extract content into a structured HTML format.',
|
19
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
20
|
+
epilog="""
|
21
|
+
Examples:
|
22
|
+
# Run from the project root directory (`content-extraction/`)
|
23
|
+
|
24
|
+
# Process a local PDF file
|
25
|
+
python src/process.py my_document.pdf -o ./output_folder
|
26
|
+
|
27
|
+
# Process a PowerPoint file silently
|
28
|
+
python src/process.py my_slides.pptx --silent
|
29
|
+
|
30
|
+
# Process a remote URL, letting the script determine the type
|
31
|
+
python src/process.py https://example.com/document.pdf
|
32
|
+
|
33
|
+
# Process a remote URL, forcing the type to be treated as HTML
|
34
|
+
python src/process.py https://example.com/some-page --force-ext html
|
35
|
+
""",
|
36
|
+
)
|
37
|
+
|
38
|
+
parser.add_argument('input_path', help='Path to the input file or a URL to process.')
|
39
|
+
parser.add_argument(
|
40
|
+
'-o',
|
41
|
+
'--output',
|
42
|
+
default='output',
|
43
|
+
help="Path to the output directory (defaults to 'output').",
|
44
|
+
)
|
45
|
+
parser.add_argument(
|
46
|
+
'--force-ext',
|
47
|
+
default=None,
|
48
|
+
help="Force the handler for a specific file extension (e.g., 'pdf', 'pptx') when auto-detection is ambiguous or incorrect.",
|
49
|
+
)
|
50
|
+
|
51
|
+
args = parser.parse_args()
|
52
|
+
|
53
|
+
logger.info(f'Processing file: {args.input_path}')
|
54
|
+
process_file(args.input_path, args.output, args.force_ext)
|
55
|
+
logger.info('Processing complete.')
|
56
|
+
|
57
|
+
|
58
|
+
if __name__ == '__main__':
|
59
|
+
sys.exit(main())
|
@@ -3,13 +3,14 @@ content_extraction/common_std_io.py,sha256=mSRaiI4OrnttEQ8Y92-LsJnAHEI3xLKnJvmXD
|
|
3
3
|
content_extraction/do_ocr.py,sha256=lrqwPYQlPuUHabirH_RzKbzHgYUPPpNeHDe_u4h9LEY,6886
|
4
4
|
content_extraction/dspy_modules.py,sha256=0aAokJQNzczfowoUNK3BPMi_U18eXM9thHvciWaE5b0,732
|
5
5
|
content_extraction/extract_from_pptx.py,sha256=IWd81sn7ZsyaQZdXP5Cgbk7GspcDYEjMnBkti-pTHQY,6572
|
6
|
-
content_extraction/file_handlers.py,sha256=
|
6
|
+
content_extraction/file_handlers.py,sha256=fEAm0Iie5qc5ex4IhOQJGWkjZK12dfzuCabkmHF1GVM,11132
|
7
7
|
content_extraction/fix_ocr.py,sha256=2xJ4c3VsGSy1l-qAukvhaV8QOp6yu5BY99Gb0DwamWQ,8009
|
8
8
|
content_extraction/logging_config.py,sha256=GN1wuJJEspQ3z-FZIg134obsHweuiicZfz2an13a9_I,296
|
9
9
|
content_extraction/parse_html.py,sha256=mOrZKXX59YcdWWhmbnoTnfXpwrg0znk38x0DMJIVes8,3137
|
10
|
+
content_extraction/process.py,sha256=iLcmSjWhEg_DbgnftnVIfybIeLCuTEI57gasot0MtDk,1809
|
10
11
|
content_extraction/semantic_chunk_html.py,sha256=iJPspKkrt95lL46JpC_9fgT8GfV8cz04TWEnU99rbBw,5786
|
11
12
|
content_extraction/split_and_create_digest.py,sha256=bKZL9Axc74zLH_VrlNjd46ZiVTQQrAY5iNJCotO-8v8,4253
|
12
|
-
content_extraction-0.
|
13
|
-
content_extraction-0.
|
14
|
-
content_extraction-0.
|
15
|
-
content_extraction-0.
|
13
|
+
content_extraction-0.2.0.dist-info/METADATA,sha256=O0GNY4Ksv4Idb5pzCbQtYc0upufn_JoadEukGJRSUc0,6201
|
14
|
+
content_extraction-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
15
|
+
content_extraction-0.2.0.dist-info/top_level.txt,sha256=a0I0EwSzsyd3p_aAENozn9i4I3aBn12XtrbqIvfzZec,19
|
16
|
+
content_extraction-0.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|