Skip to content

Commit

Permalink
Merge pull request #32 from breezedeus/dev
Browse files Browse the repository at this point in the history
fix: results from `self.recognize_by_clf` have no `line_number`
  • Loading branch information
breezedeus authored Jul 14, 2023
2 parents ab720db + 5d0ab1f commit 5eb44fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package:
rm -rf build
python setup.py sdist bdist_wheel

VERSION = 0.2.3
VERSION = 0.2.3.1
upload:
python -m twine upload dist/pix2text-$(VERSION)* --verbose

Expand Down
5 changes: 5 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release Notes

## Update 2023.07.14:发布 **V0.2.3.1**

主要变更:
* 修复了 `self.recognize_by_clf` 返回结果中不包含 `line_number` 字段导致 `merge_line_texts` 报错的bug。

## Update 2023.07.03:发布 **V0.2.3**

主要变更:
Expand Down
2 changes: 1 addition & 1 deletion pix2text/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding: utf-8
# Copyright (C) 2022-2023, [Breezedeus](https://www.breezedeus.com).

__version__ = '0.2.3'
__version__ = '0.2.3.1'
15 changes: 8 additions & 7 deletions pix2text/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,19 +420,20 @@ def merge_line_texts(
line_margin_list = [] # 每行的最左边和左右边的x坐标
isolated_included = [] # 每行是否包含了 `isolated` 类型的数学公式
for o in out:
if len(out_texts) <= o['line_number']:
line_number = o.get('line_number', 0)
if len(out_texts) <= line_number:
out_texts.append([])
line_margin_list.append([0, 0])
isolated_included.append(False)
out_texts[o['line_number']].append(o['text'])
line_margin_list[o['line_number']][1] = max(
line_margin_list[o['line_number']][1], float(o['position'][2, 0])
out_texts[line_number].append(o['text'])
line_margin_list[line_number][1] = max(
line_margin_list[line_number][1], float(o['position'][2, 0])
)
line_margin_list[o['line_number']][0] = min(
line_margin_list[o['line_number']][0], float(o['position'][0, 0])
line_margin_list[line_number][0] = min(
line_margin_list[line_number][0], float(o['position'][0, 0])
)
if o['type'] == 'isolated':
isolated_included[o['line_number']] = True
isolated_included[line_number] = True

line_text_list = [smart_join(o) for o in out_texts]

Expand Down

0 comments on commit 5eb44fe

Please sign in to comment.