Ble*_*der 9 python ocr latex tesseract
我正在尝试从OCR的图像文本的输出中重新创建段落和缩进,如下所示:
输入(想象这是一个图像,而不是键入):

输出(有一些错误):

如您所见,不会保留任何段落或缩进.
使用Python,我尝试了这样的方法,但它不起作用(经常失败):
代码:
def smart_format(text):
textList = text.split('\n')
temp = ''
averageLL = sum([len(line) for line in textList]) / len(textList)
for line in textList:
if (line.strip().endswith('!') or line.strip().endswith('.') or line.strip().endswith('?')) and not line.strip().endswith('-'):
if averageLL - len(line) > 7:
temp += '{{ paragraph }}' + line + '\n'
else:
temp += line + '\n'
else:
temp += line + '\n'
return temp.replace(' -\n', '').replace('-\n', '').replace(' \n', '').replace('\n', ' ').replace('{{ paragraph }}', '\n\n ')
Run Code Online (Sandbox Code Playgroud)
有没有人有任何建议,我可以重新创建这个布局?我正在使用旧书,所以我希望用LaTeX重新排版它们,因为创建一个Python脚本非常简单.
谢谢!