Skip to content

Commit

Permalink
Check tika.parser return result (infiniflow#3564)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Check tika.parser return result. Close infiniflow#3229

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: Yingfeng <yingfeng.zhang@gmail.com>
  • Loading branch information
yuzhichang and yingfeng authored Nov 22, 2024
1 parent 691ea28 commit 482c1b5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions rag/app/naive.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,14 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
callback(0.1, "Start to parse.")
binary = BytesIO(binary)
doc_parsed = parser.from_buffer(binary)
sections = doc_parsed['content'].split('\n')
sections = [(_, "") for _ in sections if _]
callback(0.8, "Finish parsing.")
if doc_parsed.get('content', None) is not None:
sections = doc_parsed['content'].split('\n')
sections = [(_, "") for _ in sections if _]
callback(0.8, "Finish parsing.")
else:
callback(0.8, f"tika.parser got empty content from {filename}.")
logging.warning(f"tika.parser got empty content from {filename}.")
return []

else:
raise NotImplementedError(
Expand Down

0 comments on commit 482c1b5

Please sign in to comment.