MCPcopy
hub / github.com/impira/docquery / get_ocr_reader

Function get_ocr_reader

src/docquery/ocr_reader.py:163–177  ·  view source on GitHub ↗
(ocr_reader_name: Optional[str] = None)

Source from the content-addressed store, hash-verified

161
162
163def get_ocr_reader(ocr_reader_name: Optional[str] = None):
164 if not ocr_reader_name:
165 for name, reader in OCR_MAPPING.items():
166 if OCR_AVAILABLE[name]:
167 return reader()
168
169 if ocr_reader_name in OCR_MAPPING.keys():
170 if OCR_AVAILABLE[ocr_reader_name]:
171 return OCR_MAPPING[ocr_reader_name]()
172 else:
173 raise NoOCRReaderFound(f"Failed to load: {ocr_reader_name} Please make sure its installed correctly.")
174 else:
175 raise NoOCRReaderFound(
176 f"Failed to find: {ocr_reader_name} in the available ocr libraries. The choices are: {list(OCR_MAPPING.keys())}"
177 )

Callers 6

test_get_ocr_readerFunction · 0.90
test_assert_fallbackFunction · 0.90
load_documentFunction · 0.85

Calls 1

NoOCRReaderFoundClass · 0.85

Tested by 5

test_get_ocr_readerFunction · 0.72
test_assert_fallbackFunction · 0.72