content-extraction 0.1.0__tar.gz → 0.3.0__tar.gz
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-0.1.0 → content_extraction-0.3.0}/PKG-INFO +2 -2
- {content_extraction-0.1.0 → content_extraction-0.3.0}/pyproject.toml +6 -2
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/file_handlers.py +1 -1
- content_extraction-0.3.0/src/content_extraction/process.py +59 -0
- content_extraction-0.3.0/src/content_extraction/process_document.sh +36 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/PKG-INFO +2 -2
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/SOURCES.txt +2 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/top_level.txt +0 -1
- {content_extraction-0.1.0 → content_extraction-0.3.0}/README.md +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/setup.cfg +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/__init__.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/common_std_io.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/do_ocr.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/dspy_modules.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/extract_from_pptx.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/fix_ocr.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/logging_config.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/parse_html.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/semantic_chunk_html.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/split_and_create_digest.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/dependency_links.txt +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/requires.txt +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/tests/test_section_parser.py +0 -0
- {content_extraction-0.1.0 → content_extraction-0.3.0}/tests/test_semantic_chunk_html.py +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: content_extraction
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: Project dedicated to content extraction from unstructured files that contain some useful information.
|
5
|
-
Requires-Python: >=3.
|
5
|
+
Requires-Python: >=3.12
|
6
6
|
Description-Content-Type: text/markdown
|
7
7
|
Requires-Dist: beautifulsoup4>=4.13.4
|
8
8
|
Requires-Dist: lxml>=6.0.0
|
@@ -5,18 +5,22 @@ build-backend = "setuptools.build_meta"
|
|
5
5
|
[tool.setuptools.packages.find]
|
6
6
|
where = ["src"]
|
7
7
|
|
8
|
+
[tool.setuptools.package-data]
|
9
|
+
"content_extraction" = ["process_document.sh"]
|
10
|
+
|
8
11
|
[project]
|
9
12
|
name = "content_extraction"
|
10
|
-
version = "0.
|
13
|
+
version = "0.3.0"
|
11
14
|
description = "Project dedicated to content extraction from unstructured files that contain some useful information."
|
12
15
|
readme = "README.md"
|
13
|
-
requires-python = ">=3.
|
16
|
+
requires-python = ">=3.12"
|
14
17
|
dependencies = ["beautifulsoup4>=4.13.4", "lxml>=6.0.0", "python-pptx>=1.0.2"]
|
15
18
|
|
16
19
|
[dependency-groups]
|
17
20
|
dev = [
|
18
21
|
"dspy>=2.6.27",
|
19
22
|
"jupyterlab>=4.4.5",
|
23
|
+
"mypy>=1.17.0",
|
20
24
|
"pre-commit>=4.2.0",
|
21
25
|
"pyright>=1.1.403",
|
22
26
|
"pytest>=8.4.1",
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/file_handlers.py
RENAMED
@@ -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())
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Fail immediately if any command fails
|
4
|
+
set -e
|
5
|
+
|
6
|
+
# Check if the correct number of arguments is provided
|
7
|
+
if [ "$#" -ne 2 ]; then
|
8
|
+
echo "Usage: $0 <input_file_path> <output_directory>"
|
9
|
+
exit 1
|
10
|
+
fi
|
11
|
+
|
12
|
+
INPUT_FILE="$1"
|
13
|
+
OUTPUT_DIR="$2"
|
14
|
+
|
15
|
+
# Step 1: Perform OCR and save the result to the directory
|
16
|
+
echo "Performing OCR on $INPUT_FILE..."
|
17
|
+
python -m content_extraction.do_ocr "$INPUT_FILE" -o "$OUTPUT_DIR"
|
18
|
+
|
19
|
+
# Step 2: Combine the OCR pages into a single file
|
20
|
+
echo "Combining pages into a single Markdown file..."
|
21
|
+
cd "$OUTPUT_DIR"
|
22
|
+
ls page-*.md | sort | xargs -I{} sh -c 'cat "{}"; echo; echo' > combined.md
|
23
|
+
|
24
|
+
# Step 3: Extract headings from the combined Markdown file
|
25
|
+
echo "Extracting headings from combined.md..."
|
26
|
+
grep "^#" combined.md > headings.md
|
27
|
+
|
28
|
+
# Step 4: Fix any OCR errors using provided script
|
29
|
+
echo "Fixing OCR errors..."
|
30
|
+
fixed_text=$(python -m content_extraction.fix_ocr combined.md headings.md)
|
31
|
+
echo "$fixed_text" > fixed.md
|
32
|
+
|
33
|
+
# Step 5: Render the markdown file to HTML
|
34
|
+
pandoc fixed.md -s -f markdown -t html -o index.html
|
35
|
+
|
36
|
+
echo "All processes completed successfully. Output saved in $OUTPUT_DIR"
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/PKG-INFO
RENAMED
@@ -1,8 +1,8 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: content_extraction
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: Project dedicated to content extraction from unstructured files that contain some useful information.
|
5
|
-
Requires-Python: >=3.
|
5
|
+
Requires-Python: >=3.12
|
6
6
|
Description-Content-Type: text/markdown
|
7
7
|
Requires-Dist: beautifulsoup4>=4.13.4
|
8
8
|
Requires-Dist: lxml>=6.0.0
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/SOURCES.txt
RENAMED
@@ -9,6 +9,8 @@ src/content_extraction/file_handlers.py
|
|
9
9
|
src/content_extraction/fix_ocr.py
|
10
10
|
src/content_extraction/logging_config.py
|
11
11
|
src/content_extraction/parse_html.py
|
12
|
+
src/content_extraction/process.py
|
13
|
+
src/content_extraction/process_document.sh
|
12
14
|
src/content_extraction/semantic_chunk_html.py
|
13
15
|
src/content_extraction/split_and_create_digest.py
|
14
16
|
src/content_extraction.egg-info/PKG-INFO
|
File without changes
|
File without changes
|
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/common_std_io.py
RENAMED
File without changes
|
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/dspy_modules.py
RENAMED
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/extract_from_pptx.py
RENAMED
File without changes
|
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/logging_config.py
RENAMED
File without changes
|
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction/semantic_chunk_html.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{content_extraction-0.1.0 → content_extraction-0.3.0}/src/content_extraction.egg-info/requires.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|