Check tika.parser return result (#3564)
Browse files### What problem does this PR solve?
Check tika.parser return result. Close #3229
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
Co-authored-by: Yingfeng <[email protected]>
- rag/app/naive.py +8 -3
rag/app/naive.py
CHANGED
@@ -263,9 +263,14 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
|
|
263 |
callback(0.1, "Start to parse.")
|
264 |
binary = BytesIO(binary)
|
265 |
doc_parsed = parser.from_buffer(binary)
|
266 |
-
|
267 |
-
|
268 |
-
|
|
|
|
|
|
|
|
|
|
|
269 |
|
270 |
else:
|
271 |
raise NotImplementedError(
|
|
|
263 |
callback(0.1, "Start to parse.")
|
264 |
binary = BytesIO(binary)
|
265 |
doc_parsed = parser.from_buffer(binary)
|
266 |
+
if doc_parsed.get('content', None) is not None:
|
267 |
+
sections = doc_parsed['content'].split('\n')
|
268 |
+
sections = [(_, "") for _ in sections if _]
|
269 |
+
callback(0.8, "Finish parsing.")
|
270 |
+
else:
|
271 |
+
callback(0.8, f"tika.parser got empty content from {filename}.")
|
272 |
+
logging.warning(f"tika.parser got empty content from {filename}.")
|
273 |
+
return []
|
274 |
|
275 |
else:
|
276 |
raise NotImplementedError(
|