add language setting for tesseract

This commit is contained in:
the01 2016-01-21 09:24:13 +01:00
parent 6172dcad1c
commit 4c1ff658d2
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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/