Commit ·
cd01d80
1
Parent(s): cd7e591
Clean document processor and simplify dependencies
Browse files- document_processor.py +5 -3
- requirements.txt +0 -4
document_processor.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from pathlib import Path
|
| 2 |
-
import
|
| 3 |
|
| 4 |
|
| 5 |
class DocumentProcessor:
|
|
@@ -17,7 +17,7 @@ class DocumentProcessor:
|
|
| 17 |
|
| 18 |
def process_pdf(self, path):
|
| 19 |
|
| 20 |
-
document =
|
| 21 |
|
| 22 |
pages = []
|
| 23 |
|
|
@@ -28,11 +28,13 @@ class DocumentProcessor:
|
|
| 28 |
"text": page.get_text()
|
| 29 |
})
|
| 30 |
|
|
|
|
|
|
|
| 31 |
return {
|
| 32 |
"document": {
|
| 33 |
"filename": path.name,
|
| 34 |
"format": "pdf",
|
| 35 |
-
"page_count": len(
|
| 36 |
},
|
| 37 |
"pages": pages
|
| 38 |
}
|
|
|
|
| 1 |
from pathlib import Path
|
| 2 |
+
import pymupdf
|
| 3 |
|
| 4 |
|
| 5 |
class DocumentProcessor:
|
|
|
|
| 17 |
|
| 18 |
def process_pdf(self, path):
|
| 19 |
|
| 20 |
+
document = pymupdf.open(path)
|
| 21 |
|
| 22 |
pages = []
|
| 23 |
|
|
|
|
| 28 |
"text": page.get_text()
|
| 29 |
})
|
| 30 |
|
| 31 |
+
document.close()
|
| 32 |
+
|
| 33 |
return {
|
| 34 |
"document": {
|
| 35 |
"filename": path.name,
|
| 36 |
"format": "pdf",
|
| 37 |
+
"page_count": len(pages)
|
| 38 |
},
|
| 39 |
"pages": pages
|
| 40 |
}
|
requirements.txt
CHANGED
|
@@ -1,6 +1,2 @@
|
|
| 1 |
gradio
|
| 2 |
-
docling
|
| 3 |
pymupdf
|
| 4 |
-
python-docx
|
| 5 |
-
ebooklib
|
| 6 |
-
beautifulsoup4
|
|
|
|
| 1 |
gradio
|
|
|
|
| 2 |
pymupdf
|
|
|
|
|
|
|
|
|