Use backend-specific suffixes for output filenames.
This commit is contained in:
parent
721de38920
commit
4548f92e73
2 changed files with 4 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ from .glyphdb import WhitespaceData
|
||||||
|
|
||||||
|
|
||||||
class OutputFormat(object):
|
class OutputFormat(object):
|
||||||
|
suffix = ''
|
||||||
last_tag = None
|
last_tag = None
|
||||||
|
|
||||||
def __call__(self, glyph_data_stream):
|
def __call__(self, glyph_data_stream):
|
||||||
|
|
@ -65,6 +66,7 @@ class OutputFormat(object):
|
||||||
|
|
||||||
|
|
||||||
class TextFormat(OutputFormat):
|
class TextFormat(OutputFormat):
|
||||||
|
suffix = '.txt'
|
||||||
def assign_tag(self, glyph_data):
|
def assign_tag(self, glyph_data):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
@ -73,6 +75,7 @@ class TextFormat(OutputFormat):
|
||||||
|
|
||||||
|
|
||||||
class HTMLFormat(OutputFormat):
|
class HTMLFormat(OutputFormat):
|
||||||
|
suffix = '.html'
|
||||||
def assign_glyph_tag(self, glyph_data):
|
def assign_glyph_tag(self, glyph_data):
|
||||||
style = glyph_data.style
|
style = glyph_data.style
|
||||||
if style.bold:
|
if style.bold:
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ class OCREngine(QThread):
|
||||||
self.pageChanged.emit(page)
|
self.pageChanged.emit(page)
|
||||||
page_text = self.recognize_page(page)
|
page_text = self.recognize_page(page)
|
||||||
print(page_text)
|
print(page_text)
|
||||||
with open(filename + '.txt', 'w') as page_text_file:
|
with open(filename + self.output_format.suffix, 'w') as page_text_file:
|
||||||
page_text_file.write(page_text)
|
page_text_file.write(page_text)
|
||||||
|
|
||||||
def recognize_page(self, page):
|
def recognize_page(self, page):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue