Mention FORGIVING_OCR config option when language detection fails.

It is not obvious that the PAPERLESS_FORGIVING_OCR allows to let
document consumption happen even if no language can be detected.
Mentioning it in the actual error message in the log seems like the best
way to make it clear.
This commit is contained in:
David Martin 2018-10-08 19:37:05 +11:00
parent ff809d1265
commit b0afa37ec1

View File

@ -153,7 +153,10 @@ class RasterisedDocumentParser(DocumentParser):
) )
raw_text = self._assemble_ocr_sections(imgs, middle, raw_text) raw_text = self._assemble_ocr_sections(imgs, middle, raw_text)
return raw_text return raw_text
raise OCRError("Language detection failed") error_msg = ("Language detection failed. Set "
"PAPERLESS_FORGIVING_OCR in config file to continue "
"anyway.")
raise OCRError(error_msg)
if ISO639[guessed_language] == self.DEFAULT_OCR_LANGUAGE: if ISO639[guessed_language] == self.DEFAULT_OCR_LANGUAGE:
raw_text = self._assemble_ocr_sections(imgs, middle, raw_text) raw_text = self._assemble_ocr_sections(imgs, middle, raw_text)