From 4c1ff658d2c64dc709746b021d8a558953ad6a0d Mon Sep 17 00:00:00 2001 From: the01 Date: Thu, 21 Jan 2016 09:24:13 +0100 Subject: [PATCH] add language setting for tesseract --- src/documents/management/commands/document_consumer.py | 3 ++- src/paperless/settings.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py index d8441fcf5..0dbf0988a 100644 --- a/src/documents/management/commands/document_consumer.py +++ b/src/documents/management/commands/document_consumer.py @@ -37,6 +37,7 @@ class Command(BaseCommand): CONSUME = settings.CONSUMPTION_DIR OCR = pyocr.get_available_tools()[0] + OCR_LANG = settings.TESSERACT_LANGUAGE MEDIA_PDF = os.path.join(settings.MEDIA_ROOT, "documents", "pdf") PARSER_REGEX_TITLE = re.compile(r"^.*/(.*)\.pdf$") @@ -135,7 +136,7 @@ class Command(BaseCommand): for png in pngs: with Image.open(os.path.join(self.SCRATCH, png)) as f: self._render(" {}".format(f.filename), 3) - r += self.OCR.image_to_string(f) + r += self.OCR.image_to_string(f, lang=self.OCR_LANG) r += "\n\n\n\n\n\n\n\n" return r diff --git a/src/paperless/settings.py b/src/paperless/settings.py index 377c47b2a..df6776769 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -126,6 +126,9 @@ USE_L10N = True USE_TZ = True +# Tesseract language setting +TESSERACT_LANGUAGE = "eng" + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.9/howto/static-files/