Spaces:
Running on Zero
Running on Zero
Update ingestion/ingestor.py
Browse files- ingestion/ingestor.py +6 -0
ingestion/ingestor.py
CHANGED
|
@@ -56,8 +56,14 @@ class HaqeeqatIngestor:
|
|
| 56 |
|
| 57 |
def _ingest_image(self, path: str) -> dict:
|
| 58 |
ocr_text = self.ocr_engine.extract_text(path)
|
|
|
|
| 59 |
metadata = self._base_metadata()
|
| 60 |
metadata["frames_sampled"] = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
return {
|
| 62 |
"file_type": "image",
|
| 63 |
"audio_transcript": "",
|
|
|
|
| 56 |
|
| 57 |
def _ingest_image(self, path: str) -> dict:
|
| 58 |
ocr_text = self.ocr_engine.extract_text(path)
|
| 59 |
+
garbled = utils.is_ocr_garbled(ocr_text)
|
| 60 |
metadata = self._base_metadata()
|
| 61 |
metadata["frames_sampled"] = 1
|
| 62 |
+
metadata["ocr_garbled"] = garbled
|
| 63 |
+
if garbled:
|
| 64 |
+
metadata["warnings"] = metadata.get("warnings", []) + [
|
| 65 |
+
"OCR produced garbled output; results may be unreliable"
|
| 66 |
+
]
|
| 67 |
return {
|
| 68 |
"file_type": "image",
|
| 69 |
"audio_transcript": "",
|