Skip to content

Commit

Permalink
fix: check existence of variable res before iteration (#2063)
Browse files Browse the repository at this point in the history
Fixes a bug where `TypeError: 'NoneType' object is not iterable` raises
due to variable `res` returning as None

Checks the existence of `res` before iteration
  • Loading branch information
ahmetmeleq authored Nov 14, 2023
1 parent 6c9990b commit 68686e2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 0.10.31-dev2
## 0.10.31-dev3

### Enhancements
* **Temporary Support for paddle language parameter** User can specify default langage code for paddle with ENV `DEFAULT_PADDLE_LANG` before we have the language mapping for paddle.
Expand All @@ -8,6 +8,7 @@
### Fixes
* **Remove default user ./ssh folder** The default notebook user during image build would create the known_hosts file with incorrect ownership, this is legacy and no longer needed so it was removed.
* **Include `languages` in metadata when partitioning strategy='hi_res' or 'fast'** User defined `languages` was previously used for text detection, but not included in the resulting element metadata for some strategies. `languages` will now be included in the metadata regardless of partition strategy for pdfs and images.
* **Handle a case where Paddle returns a list item in ocr_data as None** In partition, while parsing PaddleOCR data, it was assumed that PaddleOCR does not return None for any list item in ocr_data. Removed the assumption by skipping the text region whenever this happens.

## 0.10.30

Expand Down
2 changes: 1 addition & 1 deletion unstructured/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.10.31-dev2" # pragma: no cover
__version__ = "0.10.31-dev3" # pragma: no cover
3 changes: 3 additions & 0 deletions unstructured/partition/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,9 @@ def parse_ocr_data_paddle(ocr_data: list) -> List[TextRegion]:
text_regions = []
for idx in range(len(ocr_data)):
res = ocr_data[idx]
if not res:
continue

for line in res:
x1 = min([i[0] for i in line[0]])
y1 = min([i[1] for i in line[0]])
Expand Down

0 comments on commit 68686e2

Please sign in to comment.