Commit e34cb4d1 authored by David Martin's avatar David Martin

Import psm_parameter later to avoid circular import issues.

We are importing from builders.py in tesseract.py, and vice versa. So to
avoid it falling over we simply do the import of the psm_parameter only
when it is actually needed.
parent adfff7bc
......@@ -14,7 +14,6 @@ except ImportError:
import xml.dom.minidom
import logging
import pyocr.tesseract
from .util import to_unicode
logger = logging.getLogger(__name__)
......@@ -305,8 +304,9 @@ class TextBuilder(BaseBuilder):
def __init__(self, tesseract_layout=3, cuneiform_dotmatrix=False,
cuneiform_fax=False, cuneiform_singlecolumn=False):
from .tesseract import psm_parameter
tess_flags = [psm_parameter(), str(tesseract_layout)]
file_ext = ["txt"]
tess_flags = [pyocr.tesseract.psm_parameter(), str(tesseract_layout)]
cun_args = ["-f", "text"]
# Add custom cuneiform parameters if needed
for par, arg in [(cuneiform_dotmatrix, "--dotmatrix"),
......@@ -562,8 +562,9 @@ class WordBoxBuilder(BaseBuilder):
"""
def __init__(self, tesseract_layout=1):
from .tesseract import psm_parameter
tess_flags = [psm_parameter(), str(tesseract_layout)]
file_ext = ["html", "hocr"]
tess_flags = [pyocr.tesseract.psm_parameter(), str(tesseract_layout)]
tess_conf = ["hocr"]
cun_args = ["-f", "hocr"]
super(WordBoxBuilder, self).__init__(file_ext, tess_flags, tess_conf,
......@@ -638,8 +639,9 @@ class LineBoxBuilder(BaseBuilder):
"""
def __init__(self, tesseract_layout=1):
from .tesseract import psm_parameter
tess_flags = [psm_parameter(), str(tesseract_layout)]
file_ext = ["html", "hocr"]
tess_flags = [pyocr.tesseract.psm_parameter(), str(tesseract_layout)]
tess_conf = ["hocr"]
cun_args = ["-f", "hocr"]
super(LineBoxBuilder, self).__init__(file_ext, tess_flags, tess_conf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment