document-intelligence-cli 0.1.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.
Files changed (25) hide show
  1. document_intelligence_cli-0.1.0/LICENSE +21 -0
  2. document_intelligence_cli-0.1.0/PKG-INFO +498 -0
  3. document_intelligence_cli-0.1.0/README.md +481 -0
  4. document_intelligence_cli-0.1.0/pyproject.toml +50 -0
  5. document_intelligence_cli-0.1.0/setup.cfg +4 -0
  6. document_intelligence_cli-0.1.0/src/docintel/__init__.py +1 -0
  7. document_intelligence_cli-0.1.0/src/docintel/__main__.py +6 -0
  8. document_intelligence_cli-0.1.0/src/docintel/cli.py +77 -0
  9. document_intelligence_cli-0.1.0/src/docintel/extractors.py +41 -0
  10. document_intelligence_cli-0.1.0/src/docintel/processor.py +42 -0
  11. document_intelligence_cli-0.1.0/src/docintel/reader.py +4 -0
  12. document_intelligence_cli-0.1.0/src/docintel/report.py +37 -0
  13. document_intelligence_cli-0.1.0/src/docintel/validators.py +97 -0
  14. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/PKG-INFO +498 -0
  15. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/SOURCES.txt +23 -0
  16. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/dependency_links.txt +1 -0
  17. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/entry_points.txt +2 -0
  18. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/requires.txt +7 -0
  19. document_intelligence_cli-0.1.0/src/document_intelligence_cli.egg-info/top_level.txt +1 -0
  20. document_intelligence_cli-0.1.0/tests/test_cli.py +132 -0
  21. document_intelligence_cli-0.1.0/tests/test_extractors.py +253 -0
  22. document_intelligence_cli-0.1.0/tests/test_processor.py +330 -0
  23. document_intelligence_cli-0.1.0/tests/test_reader.py +42 -0
  24. document_intelligence_cli-0.1.0/tests/test_report.py +167 -0
  25. document_intelligence_cli-0.1.0/tests/test_validators.py +300 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Michael BAG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,498 @@
1
+ Metadata-Version: 2.4
2
+ Name: document-intelligence-cli
3
+ Version: 0.1.0
4
+ Summary: A CLI tool for extracting structured information from text documents.
5
+ Author-email: Michael BAG <michaelbag8@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Provides-Extra: dev
11
+ Requires-Dist: build>=1.3; extra == "dev"
12
+ Requires-Dist: pytest>=9.0; extra == "dev"
13
+ Requires-Dist: pytest-cov>=7.0; extra == "dev"
14
+ Requires-Dist: ruff>=0.13; extra == "dev"
15
+ Requires-Dist: mypy>=1.18; extra == "dev"
16
+ Dynamic: license-file
17
+
18
+ # Document Intelligence CLI
19
+
20
+ A Python command-line tool for extracting and analyzing structured information from text documents.
21
+
22
+ Document Intelligence CLI reads a text document, identifies values such as email addresses, phone numbers, dates, and IP addresses, validates the extracted candidates, and generates a human-readable report.
23
+
24
+ The project is built with a simple pipeline architecture that separates document reading, extraction, validation, processing, reporting, and command-line interaction.
25
+
26
+ ## Features
27
+
28
+ - Extract structured information from text documents
29
+ - Validate extracted values
30
+ - Generate human-readable reports
31
+ - Command-line interface using Python's `argparse`
32
+ - Run as a Python module with `python -m docintel`
33
+ - Run through the installed `docintel` command
34
+ - Handle missing files
35
+ - Handle empty documents
36
+ - Automated unit and integration tests
37
+ - No third-party runtime dependencies
38
+
39
+ ## Supported Extraction Types
40
+
41
+ The current document-processing pipeline supports:
42
+
43
+ | Type | Example |
44
+ |---|---|
45
+ | Email | `support@example.com` |
46
+ | Phone number | `+2348012345678` |
47
+ | Money | `$2,500.50` |
48
+ | Date | `2024-02-29` |
49
+ | Hashtag | `#Python` |
50
+ | Mention | `@michael` |
51
+ | IP address | `192.168.1.1` |
52
+ | URL | `https://example.com` |
53
+
54
+ The application uses two stages for most extraction types:
55
+
56
+ 1. **Extraction** identifies candidate values in the document.
57
+ 2. **Validation** determines whether the candidates satisfy the project's validation rules.
58
+
59
+ ## Requirements
60
+
61
+ - Python 3.10 or newer
62
+ - Git
63
+
64
+ The application has no third-party runtime dependencies.
65
+
66
+ `pytest` is used for development and testing.
67
+
68
+ ## Installation
69
+
70
+ ### 1. Clone the repository
71
+
72
+ ```bash
73
+ git clone https://github.com/michaelbag8/document-intelligence-cli.git
74
+ cd document-intelligence-cli
75
+ ```
76
+
77
+ ### 2. Create a virtual environment
78
+
79
+ ```bash
80
+ python3 -m venv .venv
81
+ ```
82
+
83
+ ### 3. Activate the virtual environment
84
+
85
+ #### Linux, macOS, and WSL
86
+
87
+ ```bash
88
+ source .venv/bin/activate
89
+ ```
90
+
91
+ #### Windows PowerShell
92
+
93
+ ```powershell
94
+ .venv\Scripts\Activate.ps1
95
+ ```
96
+
97
+ You should see `(.venv)` at the beginning of your terminal prompt.
98
+
99
+ ### 4. Install the project
100
+
101
+ ```bash
102
+ python -m pip install -e ".[dev]"
103
+ ```
104
+ The `-e` option installs the project in editable mode, while `[dev]` installs the development tools used by the project.
105
+
106
+ ## Usage
107
+
108
+ The CLI accepts a document path as a positional argument.
109
+
110
+ ### Run with Python
111
+
112
+ ```bash
113
+ python -m docintel sample_data/sample.txt
114
+ ```
115
+
116
+ ### Run using the installed CLI
117
+
118
+ ```bash
119
+ docintel sample_data/sample.txt
120
+ ```
121
+
122
+ Both commands execute the same application.
123
+
124
+ ## Command-Line Options
125
+
126
+ ### Display help
127
+
128
+ ```bash
129
+ python -m docintel --help
130
+ ```
131
+
132
+ or:
133
+
134
+ ```bash
135
+ docintel --help
136
+ ```
137
+
138
+ ### Display the version
139
+
140
+ ```bash
141
+ python -m docintel --version
142
+ ```
143
+
144
+ or:
145
+
146
+ ```bash
147
+ docintel --version
148
+ ```
149
+
150
+ ## Handling Different Situations
151
+
152
+ ### Existing document
153
+
154
+ ```bash
155
+ python -m docintel sample_data/sample.txt
156
+ ```
157
+
158
+ The application reads and processes the document and generates a report.
159
+
160
+ ### Missing document
161
+
162
+ ```bash
163
+ python -m docintel sample_data/does-not-exist.txt
164
+ ```
165
+
166
+ The application reports that the file does not exist and exits with a non-zero status.
167
+
168
+ ### Empty document
169
+
170
+ ```bash
171
+ python -m docintel sample_data/empty.txt
172
+ ```
173
+
174
+ The application reports:
175
+
176
+ ```text
177
+ No content found. Nothing to analyze.
178
+ ```
179
+
180
+ An empty document is treated as a valid execution rather than a processing error.
181
+
182
+ ### Missing file path
183
+
184
+ ```bash
185
+ python -m docintel
186
+ ```
187
+
188
+ `argparse` reports that the required file path argument is missing.
189
+
190
+ ## Sample Input
191
+
192
+ Example document:
193
+
194
+ ```text
195
+ Contact support@acme.com or call +2348012345678.
196
+
197
+ The transaction amount was $2,500.50 on 2024-02-29.
198
+
199
+ Follow us on #Python and contact @michael.
200
+
201
+ The server is available at 192.168.1.1.
202
+ ```
203
+
204
+ ## Sample Output
205
+
206
+ ```text
207
+ Document Intelligence Report
208
+ ===========================
209
+
210
+ Emails:
211
+ - support@acme.com
212
+
213
+ Phone Numbers:
214
+ - +2348012345678
215
+
216
+ Money:
217
+ - $2,500.50
218
+
219
+ Dates:
220
+ - 2024-02-29
221
+
222
+ Hashtags:
223
+ - #Python
224
+
225
+ Mentions:
226
+ - @michael
227
+
228
+ IP Addresses:
229
+ - 192.168.1.1
230
+ ```
231
+
232
+ The actual report depends on the contents of the document.
233
+
234
+ ## Architecture
235
+
236
+ The application follows a simple processing pipeline:
237
+
238
+ ```text
239
+ ┌──────────────┐
240
+ │ CLI │
241
+ │ cli.py │
242
+ └──────┬───────┘
243
+ │
244
+ ▼
245
+ ┌──────────────┐
246
+ │ Reader │
247
+ │ reader.py │
248
+ └──────┬───────┘
249
+ │
250
+ ▼
251
+ ┌──────────────┐
252
+ │ Processor │
253
+ │ processor.py │
254
+ └──────┬───────┘
255
+ │
256
+ ┌─────────┴─────────┐
257
+ │ │
258
+ ▼ ▼
259
+ ┌──────────────┐ ┌──────────────┐
260
+ │ Extractors │ │ Validators │
261
+ │ extractors.py│ │validators.py │
262
+ └──────────────┘ └──────────────┘
263
+ │ │
264
+ └─────────┬─────────┘
265
+ │
266
+ ▼
267
+ ┌──────────────┐
268
+ │ Report │
269
+ │ report.py │
270
+ └──────────────┘
271
+ ```
272
+
273
+ ### Project Structure
274
+
275
+ ```text
276
+ document-intelligence-cli/
277
+ ├── README.md
278
+ ├── CONTRIBUTING.md
279
+ ├── LICENSE
280
+ ├── pyproject.toml
281
+ ├── .gitignore
282
+ │
283
+ ├── sample_data/
284
+ │ ├── sample.txt
285
+ │ └── empty.txt
286
+ │
287
+ ├── src/
288
+ │ └── docintel/
289
+ │ ├── __init__.py
290
+ │ ├── cli.py
291
+ │ ├── extractors.py
292
+ │ ├── __main__.py
293
+ │ ├── processor.py
294
+ │ ├── reader.py
295
+ │ ├── report.py
296
+ │ └── validators.py
297
+ │
298
+ └── tests/
299
+ ├── test_cli.py
300
+ ├── test_extractors.py
301
+ ├── test_processor.py
302
+ ├── test_reader.py
303
+ ├── test_report.py
304
+ └── test_validators.py
305
+ ```
306
+
307
+ ### Module Responsibilities
308
+
309
+ #### `cli.py`
310
+
311
+ Handles command-line arguments and user-facing CLI behavior.
312
+
313
+ #### `reader.py`
314
+
315
+ Reads the contents of the supplied document.
316
+
317
+ #### `extractors.py`
318
+
319
+ Searches the document for candidate values using regular expressions.
320
+
321
+ For example, the email extractor searches for strings that look like email addresses.
322
+
323
+ #### `validators.py`
324
+
325
+ Validates extracted candidates against the project's validation rules.
326
+
327
+ The distinction is:
328
+
329
+ ```text
330
+ Extractor
331
+ ↓
332
+ "Does this text look like a candidate?"
333
+
334
+ Validator
335
+ ↓
336
+ "Does this candidate satisfy our rules?"
337
+ ```
338
+
339
+ #### `processor.py`
340
+
341
+ Coordinates the extractors and validators and produces the structured processing result.
342
+
343
+ #### `report.py`
344
+
345
+ Converts the processed data into a human-readable report.
346
+
347
+ #### `__main__.py`
348
+
349
+ Allows the application to be executed with:
350
+
351
+ ```bash
352
+ python -m docintel
353
+ ```
354
+
355
+ ## Testing
356
+
357
+ The project uses `pytest`.
358
+
359
+ Run the complete test suite with:
360
+
361
+ ```bash
362
+ python -m pytest
363
+ ```
364
+
365
+ The test suite covers:
366
+
367
+ * Email extraction and validation
368
+ * Phone number extraction and validation
369
+ * Money extraction and validation
370
+ * Date extraction and validation
371
+ * Hashtag extraction
372
+ * Mention extraction
373
+ * IP address extraction and validation
374
+ * URL extraction and validation
375
+ * Document reading
376
+ * Document processing
377
+ * Report generation
378
+ * Empty documents
379
+ * Missing files
380
+ * CLI help
381
+ * CLI version
382
+ * CLI execution
383
+
384
+ ### Run a Specific Test File
385
+
386
+ ```bash
387
+ python -m pytest tests/test_extractors.py
388
+ ```
389
+
390
+ ### Run a Specific Test
391
+
392
+ ```bash
393
+ python -m pytest tests/test_validators.py::test_valid_email
394
+ ```
395
+
396
+ ## Development
397
+
398
+ ### Set Up the Development Environment
399
+
400
+ ```bash
401
+ git clone https://github.com/michaelbag8/document-intelligence-cli.git
402
+ cd document-intelligence-cli
403
+
404
+ python3 -m venv .venv
405
+ source .venv/bin/activate
406
+
407
+ python -m pip install -e ".[dev]"
408
+ ```
409
+
410
+ ### Run the Application
411
+
412
+ ```bash
413
+ python -m docintel sample_data/sample.txt
414
+ ```
415
+
416
+ ### Run Tests
417
+
418
+ ```bash
419
+ python -m pytest
420
+ ```
421
+
422
+ ### Development Workflow
423
+
424
+ When changing the project:
425
+
426
+ ```text
427
+ Understand the existing behavior
428
+ ↓
429
+ Identify the responsible module
430
+ ↓
431
+ Make the change
432
+ ↓
433
+ Add or update tests
434
+ ↓
435
+ Run the test suite
436
+ ↓
437
+ Review the result
438
+ ```
439
+
440
+ Changes to functionality should be accompanied by appropriate tests.
441
+
442
+ ## Limitations
443
+
444
+ Document Intelligence CLI currently uses pattern-based extraction and validation. It is not intended to recognize every possible representation of every supported data type.
445
+
446
+ Current limitations include:
447
+
448
+ * Extraction relies primarily on regular expressions.
449
+ * Supported formats are intentionally limited.
450
+ * Phone numbers follow the project's current digit and length rules.
451
+ * Money extraction currently focuses on dollar amounts.
452
+ * Dates use the `YYYY-MM-DD` format.
453
+ * IP addresses are extracted as candidates and then validated as IPv4 addresses.
454
+ * Hashtags and mentions follow the project's current regular-expression rules.
455
+ * URL extraction and validation follow the project's current URL rules.
456
+ * The application currently processes readable UTF-8 text documents.
457
+ * PDF and Microsoft Word documents are not currently supported.
458
+ * The application does not determine whether an extracted email address, URL, phone number, or IP address actually exists or is reachable.
459
+
460
+ ## Future Improvements
461
+
462
+ Possible future improvements include:
463
+
464
+ * Support additional date formats
465
+ * Improve phone number handling
466
+ * Support additional currencies
467
+ * Support additional document formats
468
+ * Add configurable extraction rules
469
+ * Add JSON output
470
+ * Improve report customization
471
+ * Add more comprehensive end-to-end CLI tests
472
+
473
+ ## Returning to the Project
474
+
475
+ If the project has already been installed and `.venv` exists, activate the existing environment:
476
+
477
+ ```bash
478
+ cd document-intelligence-cli
479
+ source .venv/bin/activate
480
+ ```
481
+
482
+ Then run:
483
+
484
+ ```bash
485
+ python -m docintel sample_data/sample.txt
486
+ ```
487
+
488
+ If the virtual environment does not exist, create it first:
489
+
490
+ ```bash
491
+ python3 -m venv .venv
492
+ source .venv/bin/activate
493
+ python -m pip install -e .
494
+ ```
495
+
496
+ ## License
497
+
498
+ This project is licensed under the MIT License.