automated-document-parser 0.1.5__tar.gz → 0.1.6__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.
Files changed (56) hide show
  1. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/PKG-INFO +93 -14
  2. automated_document_parser-0.1.6/README.md +147 -0
  3. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/index.rst +56 -7
  4. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/notebook_examples/rag_example.ipynb +18 -8
  5. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/pyproject.toml +1 -1
  6. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/core.py +31 -7
  7. automated_document_parser-0.1.5/README.md +0 -68
  8. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/.github/workflows/ci.yml +0 -0
  9. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/.github/workflows/docs.yml +0 -0
  10. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/.github/workflows/publish.yml +0 -0
  11. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/.gitignore +0 -0
  12. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/.pre-commit-config.yaml +0 -0
  13. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/LICENSE +0 -0
  14. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/Makefile +0 -0
  15. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/.nojekyll +0 -0
  16. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/Makefile +0 -0
  17. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/README.md +0 -0
  18. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/api.rst +0 -0
  19. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/conf.py +0 -0
  20. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/docs/modules.rst +0 -0
  21. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/notebook_examples/sample_docs/data.csv +0 -0
  22. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/notebook_examples/sample_docs/machine_learning.txt +0 -0
  23. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/notebook_examples/sample_docs/python_basics.txt +0 -0
  24. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/requirements.txt +0 -0
  25. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/__init__.py +0 -0
  26. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/config.py +0 -0
  27. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/__init__.py +0 -0
  28. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/__init__.py +0 -0
  29. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/base.py +0 -0
  30. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/csv_loader.py +0 -0
  31. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/docx_loader.py +0 -0
  32. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/html_loader.py +0 -0
  33. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/json_loader.py +0 -0
  34. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_load/text_loader.py +0 -0
  35. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/file_loaders.py +0 -0
  36. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/__init__.py +0 -0
  37. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/base.py +0 -0
  38. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/loader.py +0 -0
  39. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/mathpix_loader.py +0 -0
  40. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/opendataloader_loader.py +0 -0
  41. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/pdfplumber_loader.py +0 -0
  42. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/pymupdf4llm_loader.py +0 -0
  43. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/pymupdf_loader.py +0 -0
  44. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/pypdf_loader.py +0 -0
  45. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/pypdfium2_loader.py +0 -0
  46. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/textract_loader.py +0 -0
  47. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/loaders/pdf_load/unstructured_loader.py +0 -0
  48. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/main.py +0 -0
  49. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/src/automated_document_parser/utils.py +0 -0
  50. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/__init__.py +0 -0
  51. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_config.py +0 -0
  52. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_core.py +0 -0
  53. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_file_loaders.py +0 -0
  54. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_main.py +0 -0
  55. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_pdf_loaders.py +0 -0
  56. {automated_document_parser-0.1.5 → automated_document_parser-0.1.6}/test/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: automated-document-parser
3
- Version: 0.1.5
3
+ Version: 0.1.6
4
4
  Summary: A powerful and automated document parser built with LangChain for intelligent document processing
5
5
  Project-URL: Homepage, https://github.com/Pulkit12dhingra/automated-document-parser
6
6
  Project-URL: Documentation, https://pulkit12dhingra.github.io/automated-document-parser/
@@ -71,11 +71,38 @@ A powerful and automated document parser built with LangChain for intelligent do
71
71
  ## Features
72
72
 
73
73
  - **Automatic file type detection** based on file extensions
74
+ - **Multiple PDF loading methods** - 9 different PDF loaders for various use cases
75
+ - **Modular architecture** - Clean separation with `file_load/` and `pdf_load/` modules
74
76
  - **Support for multiple document formats**: PDF, TXT, CSV, JSON, DOCX, HTML, Markdown
75
77
  - Built on LangChain for seamless integration with RAG applications
76
78
  - Type-safe implementation with comprehensive error handling
77
79
  - Batch processing support for multiple documents
78
80
 
81
+ ## Supported File Types
82
+
83
+ ### Text Files
84
+ - `.txt` - Plain text files
85
+ - `.md` - Markdown files
86
+
87
+ ### Structured Data
88
+ - `.csv` - CSV files with encoding support
89
+ - `.json` - JSON files with jq schema filtering
90
+
91
+ ### Documents
92
+ - `.docx` - Microsoft Word documents
93
+ - `.html` - HTML files
94
+
95
+ ### PDF Files (9 loading methods)
96
+ - `pypdf` - Basic PDF text extraction (default, no extra dependencies)
97
+ - `unstructured` - Advanced OCR and layout detection
98
+ - `amazon_textract` - AWS Textract for high-accuracy OCR
99
+ - `mathpix` - Specialized for mathematical formulas
100
+ - `pdfplumber` - High accuracy text and table extraction
101
+ - `pypdfium2` - Google PDFium library
102
+ - `pymupdf` - PyMuPDF (fitz) backend
103
+ - `pymupdf4llm` - LLM-optimized extraction
104
+ - `opendataloader` - Advanced multi-format parsing
105
+
79
106
  ## Installation
80
107
 
81
108
  Install from PyPI:
@@ -92,7 +119,9 @@ uv add automated-document-parser
92
119
 
93
120
  ## Quick Start
94
121
 
95
- ### Basic Usage
122
+ ### Basic Usage - Automatic File Type Detection
123
+
124
+ The primary feature is **automatic file type detection**. Just point to any supported file and the parser handles the rest:
96
125
 
97
126
  ```python
98
127
  from automated_document_parser import DocumentParser
@@ -100,22 +129,72 @@ from automated_document_parser import DocumentParser
100
129
  # Initialize the parser
101
130
  parser = DocumentParser()
102
131
 
103
- # Parse a single document
104
- documents = parser.parse("path/to/document.pdf")
105
-
106
- # Parse multiple documents
107
- file_paths = ["doc1.pdf", "doc2.txt", "data.csv"]
108
- parsed_docs = parser.parse_multiple(file_paths)
132
+ # Parse any single file - automatically detects type and uses the right loader
133
+ documents = parser.parse("document.pdf") # Auto-detects PDF
134
+ documents = parser.parse("data.csv") # Auto-detects CSV
135
+ documents = parser.parse("notes.txt") # Auto-detects text file
136
+
137
+ # Parse multiple files of different types - all formats handled automatically
138
+ file_paths = ["report.pdf", "data.csv", "notes.txt", "info.docx"]
139
+ all_docs = parser.parse_multiple(file_paths) # Each file auto-detected and loaded
140
+
141
+ # Access parsed content
142
+ for file_path, docs in all_docs.items():
143
+ print(f"File: {file_path}")
144
+ for doc in docs:
145
+ print(f" Content: {doc.page_content[:100]}...")
146
+ print(f" Metadata: {doc.metadata}")
109
147
  ```
110
148
 
111
- ### Working with Parsed Documents
149
+ ### Specify Loading Methods
150
+
151
+ Specify the PDF loading method and other parameters to apply to all files:
112
152
 
113
153
  ```python
114
- # Access document content and metadata
115
- for doc in documents:
116
- print(f"Content: {doc.page_content}")
117
- print(f"Source: {doc.metadata['source']}")
118
- print(f"Type: {doc.metadata['file_type']}")
154
+ from automated_document_parser import DocumentParser
155
+
156
+ parser = DocumentParser()
157
+
158
+ # Step 1: Specify the method for PDFs
159
+ # Step 2: Parser automatically detects file types and loads them with specified method
160
+ file_paths = ["report1.pdf", "report2.pdf", "data.csv", "notes.txt"]
161
+ all_docs = parser.parse_multiple(
162
+ file_paths,
163
+ pdf_loader_method="pdfplumber", # All PDFs will use pdfplumber
164
+ encoding="utf-8" # All text files will use UTF-8 encoding
165
+ )
166
+
167
+ # Each file is automatically detected and loaded with the specified settings
168
+ for file_path, docs in all_docs.items():
169
+ print(f"Loaded {file_path}: {len(docs)} documents")
170
+ ```
171
+
172
+ ## Documentation
173
+
174
+ Full documentation is available at: https://pulkit12dhingra.github.io/automated-document-parser/
175
+
176
+ ## Architecture
177
+
178
+ The library uses a modular architecture:
179
+
180
+ ```
181
+ automated_document_parser/
182
+ ├── loaders/
183
+ │ ├── file_load/ # File loaders module
184
+ │ │ ├── base.py # Base file loader class
185
+ │ │ ├── text_loader.py # Text file loader
186
+ │ │ ├── csv_loader.py # CSV loader
187
+ │ │ ├── json_loader.py # JSON loader
188
+ │ │ ├── docx_loader.py # DOCX loader
189
+ │ │ └── html_loader.py # HTML loader
190
+ │ ├── pdf_load/ # PDF loaders module
191
+ │ │ ├── base.py # Base PDF loader class
192
+ │ │ ├── pypdf_loader.py
193
+ │ │ ├── mathpix_loader.py
194
+ │ │ ├── pdfplumber_loader.py
195
+ │ │ └── ... (9 PDF loaders total)
196
+ │ └── file_loaders.py # Main orchestrator
197
+ └── core.py # DocumentParser class
119
198
  ```
120
199
 
121
200
  ## License
@@ -0,0 +1,147 @@
1
+ # Automated Document Parser
2
+
3
+ [![PyPI version](https://badge.fury.io/py/automated-document-parser.svg)](https://pypi.org/project/automated-document-parser/)
4
+ [![Python Version](https://img.shields.io/pypi/pyversions/automated-document-parser.svg)](https://pypi.org/project/automated-document-parser/)
5
+ [![CI](https://github.com/Pulkit12dhingra/automated-document-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/Pulkit12dhingra/automated-document-parser/actions/workflows/ci.yml)
6
+ [![codecov](https://codecov.io/gh/Pulkit12dhingra/automated-document-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/Pulkit12dhingra/automated-document-parser)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
9
+
10
+ A powerful and automated document parser built with LangChain for intelligent document processing. This library automatically detects file types and uses the appropriate loader to parse documents into LangChain-compatible formats.
11
+
12
+ ## Features
13
+
14
+ - **Automatic file type detection** based on file extensions
15
+ - **Multiple PDF loading methods** - 9 different PDF loaders for various use cases
16
+ - **Modular architecture** - Clean separation with `file_load/` and `pdf_load/` modules
17
+ - **Support for multiple document formats**: PDF, TXT, CSV, JSON, DOCX, HTML, Markdown
18
+ - Built on LangChain for seamless integration with RAG applications
19
+ - Type-safe implementation with comprehensive error handling
20
+ - Batch processing support for multiple documents
21
+
22
+ ## Supported File Types
23
+
24
+ ### Text Files
25
+ - `.txt` - Plain text files
26
+ - `.md` - Markdown files
27
+
28
+ ### Structured Data
29
+ - `.csv` - CSV files with encoding support
30
+ - `.json` - JSON files with jq schema filtering
31
+
32
+ ### Documents
33
+ - `.docx` - Microsoft Word documents
34
+ - `.html` - HTML files
35
+
36
+ ### PDF Files (9 loading methods)
37
+ - `pypdf` - Basic PDF text extraction (default, no extra dependencies)
38
+ - `unstructured` - Advanced OCR and layout detection
39
+ - `amazon_textract` - AWS Textract for high-accuracy OCR
40
+ - `mathpix` - Specialized for mathematical formulas
41
+ - `pdfplumber` - High accuracy text and table extraction
42
+ - `pypdfium2` - Google PDFium library
43
+ - `pymupdf` - PyMuPDF (fitz) backend
44
+ - `pymupdf4llm` - LLM-optimized extraction
45
+ - `opendataloader` - Advanced multi-format parsing
46
+
47
+ ## Installation
48
+
49
+ Install from PyPI:
50
+
51
+ ```bash
52
+ pip install automated-document-parser
53
+ ```
54
+
55
+ Or using uv:
56
+
57
+ ```bash
58
+ uv add automated-document-parser
59
+ ```
60
+
61
+ ## Quick Start
62
+
63
+ ### Basic Usage - Automatic File Type Detection
64
+
65
+ The primary feature is **automatic file type detection**. Just point to any supported file and the parser handles the rest:
66
+
67
+ ```python
68
+ from automated_document_parser import DocumentParser
69
+
70
+ # Initialize the parser
71
+ parser = DocumentParser()
72
+
73
+ # Parse any single file - automatically detects type and uses the right loader
74
+ documents = parser.parse("document.pdf") # Auto-detects PDF
75
+ documents = parser.parse("data.csv") # Auto-detects CSV
76
+ documents = parser.parse("notes.txt") # Auto-detects text file
77
+
78
+ # Parse multiple files of different types - all formats handled automatically
79
+ file_paths = ["report.pdf", "data.csv", "notes.txt", "info.docx"]
80
+ all_docs = parser.parse_multiple(file_paths) # Each file auto-detected and loaded
81
+
82
+ # Access parsed content
83
+ for file_path, docs in all_docs.items():
84
+ print(f"File: {file_path}")
85
+ for doc in docs:
86
+ print(f" Content: {doc.page_content[:100]}...")
87
+ print(f" Metadata: {doc.metadata}")
88
+ ```
89
+
90
+ ### Specify Loading Methods
91
+
92
+ Specify the PDF loading method and other parameters to apply to all files:
93
+
94
+ ```python
95
+ from automated_document_parser import DocumentParser
96
+
97
+ parser = DocumentParser()
98
+
99
+ # Step 1: Specify the method for PDFs
100
+ # Step 2: Parser automatically detects file types and loads them with specified method
101
+ file_paths = ["report1.pdf", "report2.pdf", "data.csv", "notes.txt"]
102
+ all_docs = parser.parse_multiple(
103
+ file_paths,
104
+ pdf_loader_method="pdfplumber", # All PDFs will use pdfplumber
105
+ encoding="utf-8" # All text files will use UTF-8 encoding
106
+ )
107
+
108
+ # Each file is automatically detected and loaded with the specified settings
109
+ for file_path, docs in all_docs.items():
110
+ print(f"Loaded {file_path}: {len(docs)} documents")
111
+ ```
112
+
113
+ ## Documentation
114
+
115
+ Full documentation is available at: https://pulkit12dhingra.github.io/automated-document-parser/
116
+
117
+ ## Architecture
118
+
119
+ The library uses a modular architecture:
120
+
121
+ ```
122
+ automated_document_parser/
123
+ ├── loaders/
124
+ │ ├── file_load/ # File loaders module
125
+ │ │ ├── base.py # Base file loader class
126
+ │ │ ├── text_loader.py # Text file loader
127
+ │ │ ├── csv_loader.py # CSV loader
128
+ │ │ ├── json_loader.py # JSON loader
129
+ │ │ ├── docx_loader.py # DOCX loader
130
+ │ │ └── html_loader.py # HTML loader
131
+ │ ├── pdf_load/ # PDF loaders module
132
+ │ │ ├── base.py # Base PDF loader class
133
+ │ │ ├── pypdf_loader.py
134
+ │ │ ├── mathpix_loader.py
135
+ │ │ ├── pdfplumber_loader.py
136
+ │ │ └── ... (9 PDF loaders total)
137
+ │ └── file_loaders.py # Main orchestrator
138
+ └── core.py # DocumentParser class
139
+ ```
140
+
141
+ ## License
142
+
143
+ MIT License - see LICENSE file for details.
144
+
145
+ ## Contributing
146
+
147
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -8,12 +8,12 @@ Welcome to the Automated Document Parser documentation!
8
8
  Features
9
9
  --------
10
10
 
11
- * 🚀 **Automatic File Type Detection** - Intelligently detects and processes 10+ file formats
12
- * 📄 **Multiple PDF Loaders** - 9 different PDF loading methods for various use cases
13
- * 🔧 **Modular Architecture** - Clean separation with ``file_load/`` and ``pdf_load/`` modules
14
- * 🎯 **Easy Integration** - Simple API that works seamlessly with LangChain
15
- * 📊 **Structured Data Support** - Handle CSV, JSON, and other structured formats
16
- * 🔌 **Extensible Design** - Easy to add custom loaders
11
+ * **Automatic File Type Detection** - Intelligently detects and processes 10+ file formats
12
+ * **Multiple PDF Loaders** - 9 different PDF loading methods for various use cases
13
+ * **Modular Architecture** - Clean separation with ``file_load/`` and ``pdf_load/`` modules
14
+ * **Easy Integration** - Simple API that works seamlessly with LangChain
15
+ * **Structured Data Support** - Handle CSV, JSON, and other structured formats
16
+ * **Extensible Design** - Easy to add custom loaders
17
17
 
18
18
  Supported File Types
19
19
  ---------------------
@@ -54,6 +54,10 @@ Installation
54
54
  Basic Usage
55
55
  ~~~~~~~~~~~
56
56
 
57
+ **Step 1: Automatic File Type Detection**
58
+
59
+ The parser automatically detects file types and loads them with sensible defaults:
60
+
57
61
  .. code-block:: python
58
62
 
59
63
  from automated_document_parser import DocumentParser
@@ -64,13 +68,58 @@ Basic Usage
64
68
  # Parse a single document (auto-detects file type)
65
69
  documents = parser.parse("path/to/document.pdf")
66
70
 
67
- # Parse multiple documents
71
+ # Parse multiple documents (auto-detects each file type)
68
72
  files = ["doc1.txt", "data.csv", "report.pdf"]
69
73
  results = parser.parse_multiple(files)
70
74
 
75
+ **Step 2: Specify Loading Methods**
76
+
77
+ You can specify loading methods and parameters that apply to all appropriate files:
78
+
79
+ .. code-block:: python
80
+
81
+ # Specify PDF loading method for all PDFs
82
+ files = ["doc1.txt", "data.csv", "report.pdf", "paper.pdf"]
83
+ results = parser.parse_multiple(
84
+ files,
85
+ pdf_loader_method="pdfplumber" # Applies to all PDF files
86
+ )
87
+
88
+ # Specify encoding for text files
89
+ results = parser.parse_multiple(
90
+ files,
91
+ encoding="utf-8" # Applies to all text files
92
+ )
93
+
94
+ # Combine multiple parameters
95
+ results = parser.parse_multiple(
96
+ files,
97
+ pdf_loader_method="pymupdf",
98
+ encoding="utf-8"
99
+ )
100
+
101
+ Single File with Parameters
102
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
103
+
104
+ .. code-block:: python
105
+
106
+ # Parse single PDF with specific method
107
+ documents = parser.parse(
108
+ "document.pdf",
109
+ pdf_loader_method="pdfplumber"
110
+ )
111
+
112
+ # Parse text file with encoding
113
+ documents = parser.parse(
114
+ "file.txt",
115
+ encoding="utf-8"
116
+ )
117
+
71
118
  Advanced PDF Loading
72
119
  ~~~~~~~~~~~~~~~~~~~~
73
120
 
121
+ For more control, use PDFLoader directly:
122
+
74
123
  .. code-block:: python
75
124
 
76
125
  from automated_document_parser.loaders import PDFLoader
@@ -201,12 +201,17 @@
201
201
  "source": [
202
202
  "## 5. Load Documents Using Automated Document Parser\n",
203
203
  "\n",
204
- "Now we'll use our custom DocumentParser to automatically detect and load documents of different formats. The parser intelligently detects file types based on extensions and uses the appropriate loader."
204
+ "Now we'll use DocumentParser with automatic file type detection:\n",
205
+ "\n",
206
+ "**Step 1:** Specify the loading method (optional - uses defaults if not specified)\n",
207
+ "**Step 2:** Parser automatically detects file types and loads them with the specified settings\n",
208
+ "\n",
209
+ "The parser intelligently detects file types based on extensions and uses the appropriate loader for each file."
205
210
  ]
206
211
  },
207
212
  {
208
213
  "cell_type": "code",
209
- "execution_count": 4,
214
+ "execution_count": null,
210
215
  "id": "134a111a",
211
216
  "metadata": {},
212
217
  "outputs": [
@@ -240,8 +245,13 @@
240
245
  "# Get all files in the sample directory\n",
241
246
  "file_paths = [str(f) for f in sample_docs_dir.glob(\"*\") if f.is_file()]\n",
242
247
  "\n",
243
- "# Parse all documents using our automated parser\n",
244
- "parsed_docs = parser.parse_multiple(file_paths)\n",
248
+ "# Step 1: Specify the method (optional - defaults shown here)\n",
249
+ "# Step 2: Parser automatically detects each file type and loads appropriately\n",
250
+ "parsed_docs = parser.parse_multiple(\n",
251
+ " file_paths,\n",
252
+ " pdf_loader_method=\"pypdf\", # Method for PDF files (if any)\n",
253
+ " encoding=\"utf-8\" # Encoding for text/CSV files\n",
254
+ ")\n",
245
255
  "\n",
246
256
  "# Display loaded documents\n",
247
257
  "total_docs = sum(len(docs) for docs in parsed_docs.values())\n",
@@ -842,7 +852,7 @@
842
852
  },
843
853
  {
844
854
  "cell_type": "code",
845
- "execution_count": 12,
855
+ "execution_count": null,
846
856
  "id": "50de9cad",
847
857
  "metadata": {},
848
858
  "outputs": [
@@ -885,7 +895,7 @@
885
895
  "all_files = [str(f) for f in sample_docs_dir.glob(\"*\") if f.is_file()]\n",
886
896
  "results = parser.parse_multiple(all_files)\n",
887
897
  "\n",
888
- "print(f\"\\n✓ Successfully parsed {len(results)} files\")\n",
898
+ "print(f\"\\nSuccessfully parsed {len(results)} files\")\n",
889
899
  "for file_path, docs in results.items():\n",
890
900
  " file_name = Path(file_path).name\n",
891
901
  " file_type = Path(file_path).suffix\n",
@@ -903,7 +913,7 @@
903
913
  "source": [
904
914
  "## Summary\n",
905
915
  "\n",
906
- "**Congratulations!** You've learned how to:\n",
916
+ "Congratulations! You've learned how to:\n",
907
917
  "\n",
908
918
  "1. Set up a complete RAG application with HuggingFace models\n",
909
919
  "2. Use the automated document parser to load various file types\n",
@@ -927,7 +937,7 @@
927
937
  "3. Use larger, more powerful models for production\n",
928
938
  "4. Integrate with your own applications\n",
929
939
  "\n",
930
- "Happy coding! 🚀"
940
+ "Happy coding!"
931
941
  ]
932
942
  }
933
943
  ],
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "automated-document-parser"
7
- version = "0.1.5"
7
+ version = "0.1.6"
8
8
  description = "A powerful and automated document parser built with LangChain for intelligent document processing"
9
9
  readme = { file = "README.md", content-type = "text/markdown" }
10
10
  requires-python = ">=3.13"
@@ -24,12 +24,18 @@ class DocumentParser:
24
24
  """Initialize the DocumentParser."""
25
25
  self.loaded_files: List[str] = []
26
26
 
27
- def parse(self, file_path: str | Path) -> List[Document]:
27
+ def parse(
28
+ self, file_path: str | Path, pdf_loader_method: str = "pypdf", **kwargs
29
+ ) -> List[Document]:
28
30
  """
29
31
  Parse a document from file path.
30
32
 
31
33
  Args:
32
34
  file_path: Path to the document file
35
+ pdf_loader_method: Method to use for PDF files (default: 'pypdf').
36
+ Options: 'pypdf', 'unstructured', 'amazon_textract', 'mathpix',
37
+ 'pdfplumber', 'pypdfium2', 'pymupdf', 'pymupdf4llm', 'opendataloader'
38
+ **kwargs: Additional keyword arguments for the loader (e.g., encoding, api_key)
33
39
 
34
40
  Returns:
35
41
  List of LangChain Document objects
@@ -41,8 +47,13 @@ class DocumentParser:
41
47
 
42
48
  Example:
43
49
  >>> parser = DocumentParser()
50
+ >>> # Basic usage with auto-detection
44
51
  >>> docs = parser.parse("document.pdf")
45
- >>> print(f"Loaded {len(docs)} documents")
52
+ >>> # Specify PDF loading method
53
+ >>> docs = parser.parse("document.pdf", pdf_loader_method="pdfplumber")
54
+ >>> # Pass additional parameters
55
+ >>> docs = parser.parse("math.pdf", pdf_loader_method="mathpix",
56
+ ... mathpix_app_id="id", mathpix_app_key="key")
46
57
  """
47
58
  if not is_supported_file(file_path):
48
59
  path = Path(file_path)
@@ -51,7 +62,7 @@ class DocumentParser:
51
62
  f"Supported types: .txt, .pdf, .csv, .json, .docx, .html, .md"
52
63
  )
53
64
 
54
- loader = FileLoader(file_path)
65
+ loader = FileLoader(file_path, pdf_loader_method=pdf_loader_method, **kwargs)
55
66
  documents = loader.load()
56
67
 
57
68
  # Track loaded files
@@ -72,27 +83,40 @@ class DocumentParser:
72
83
  return documents
73
84
 
74
85
  def parse_multiple(
75
- self, file_paths: List[Union[str, Path]]
86
+ self,
87
+ file_paths: List[Union[str, Path]],
88
+ pdf_loader_method: str = "pypdf",
89
+ **kwargs,
76
90
  ) -> dict[str, List[Document]]:
77
91
  """
78
- Parse multiple documents.
92
+ Parse multiple documents with automatic file type detection.
79
93
 
80
94
  Args:
81
95
  file_paths: List of file paths
96
+ pdf_loader_method: Method to use for PDF files (default: 'pypdf').
97
+ Options: 'pypdf', 'unstructured', 'amazon_textract', 'mathpix',
98
+ 'pdfplumber', 'pypdfium2', 'pymupdf', 'pymupdf4llm', 'opendataloader'
99
+ **kwargs: Additional keyword arguments for loaders (e.g., encoding, api_key)
82
100
 
83
101
  Returns:
84
102
  Dictionary mapping file paths to their loaded documents
85
103
 
86
104
  Example:
87
105
  >>> parser = DocumentParser()
88
- >>> results = parser.parse_multiple(["doc1.pdf", "doc2.txt"])
106
+ >>> # Auto-detect all file types with default settings
107
+ >>> results = parser.parse_multiple(["doc1.pdf", "doc2.txt", "data.csv"])
108
+ >>> # Specify PDF method for all PDFs
109
+ >>> results = parser.parse_multiple(
110
+ ... ["doc1.pdf", "doc2.pdf", "data.csv"],
111
+ ... pdf_loader_method="pdfplumber"
112
+ ... )
89
113
  >>> for file, docs in results.items():
90
114
  ... print(f"{file}: {len(docs)} documents")
91
115
  """
92
116
  results = {}
93
117
  for file_path in file_paths:
94
118
  try:
95
- documents = self.parse(file_path)
119
+ documents = self.parse(file_path, pdf_loader_method, **kwargs)
96
120
  results[str(file_path)] = documents
97
121
  except Exception as e:
98
122
  logger.error(f"Failed to parse {file_path}: {e}")
@@ -1,68 +0,0 @@
1
- # Automated Document Parser
2
-
3
- [![PyPI version](https://badge.fury.io/py/automated-document-parser.svg)](https://pypi.org/project/automated-document-parser/)
4
- [![Python Version](https://img.shields.io/pypi/pyversions/automated-document-parser.svg)](https://pypi.org/project/automated-document-parser/)
5
- [![CI](https://github.com/Pulkit12dhingra/automated-document-parser/actions/workflows/ci.yml/badge.svg)](https://github.com/Pulkit12dhingra/automated-document-parser/actions/workflows/ci.yml)
6
- [![codecov](https://codecov.io/gh/Pulkit12dhingra/automated-document-parser/branch/master/graph/badge.svg)](https://codecov.io/gh/Pulkit12dhingra/automated-document-parser)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
9
-
10
- A powerful and automated document parser built with LangChain for intelligent document processing. This library automatically detects file types and uses the appropriate loader to parse documents into LangChain-compatible formats.
11
-
12
- ## Features
13
-
14
- - **Automatic file type detection** based on file extensions
15
- - **Support for multiple document formats**: PDF, TXT, CSV, JSON, DOCX, HTML, Markdown
16
- - Built on LangChain for seamless integration with RAG applications
17
- - Type-safe implementation with comprehensive error handling
18
- - Batch processing support for multiple documents
19
-
20
- ## Installation
21
-
22
- Install from PyPI:
23
-
24
- ```bash
25
- pip install automated-document-parser
26
- ```
27
-
28
- Or using uv:
29
-
30
- ```bash
31
- uv add automated-document-parser
32
- ```
33
-
34
- ## Quick Start
35
-
36
- ### Basic Usage
37
-
38
- ```python
39
- from automated_document_parser import DocumentParser
40
-
41
- # Initialize the parser
42
- parser = DocumentParser()
43
-
44
- # Parse a single document
45
- documents = parser.parse("path/to/document.pdf")
46
-
47
- # Parse multiple documents
48
- file_paths = ["doc1.pdf", "doc2.txt", "data.csv"]
49
- parsed_docs = parser.parse_multiple(file_paths)
50
- ```
51
-
52
- ### Working with Parsed Documents
53
-
54
- ```python
55
- # Access document content and metadata
56
- for doc in documents:
57
- print(f"Content: {doc.page_content}")
58
- print(f"Source: {doc.metadata['source']}")
59
- print(f"Type: {doc.metadata['file_type']}")
60
- ```
61
-
62
- ## License
63
-
64
- MIT License - see LICENSE file for details.
65
-
66
- ## Contributing
67
-
68
- Contributions are welcome! Please feel free to submit a Pull Request.