Kevin Hu commited on
Commit
872406f
·
1 Parent(s): d0b6637

Let 'One' applicable for tables in docx (#3619)

Browse files

### What problem does this PR solve?

#3598

### Type of change

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

Files changed (1) hide show
  1. rag/app/one.py +5 -2
rag/app/one.py CHANGED
@@ -16,7 +16,7 @@ from io import BytesIO
16
  import re
17
 
18
  from deepdoc.parser.utils import get_text
19
- from rag.app import laws
20
  from rag.nlp import rag_tokenizer, tokenize
21
  from deepdoc.parser import PdfParser, ExcelParser, PlainParser, HtmlParser
22
 
@@ -67,7 +67,10 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
67
 
68
  if re.search(r"\.docx$", filename, re.IGNORECASE):
69
  callback(0.1, "Start to parse.")
70
- sections = [txt for txt in laws.Docx()(filename, binary) if txt]
 
 
 
71
  callback(0.8, "Finish parsing.")
72
 
73
  elif re.search(r"\.pdf$", filename, re.IGNORECASE):
 
16
  import re
17
 
18
  from deepdoc.parser.utils import get_text
19
+ from rag.app import naive
20
  from rag.nlp import rag_tokenizer, tokenize
21
  from deepdoc.parser import PdfParser, ExcelParser, PlainParser, HtmlParser
22
 
 
67
 
68
  if re.search(r"\.docx$", filename, re.IGNORECASE):
69
  callback(0.1, "Start to parse.")
70
+ sections, tbls = naive.Docx()(filename, binary)
71
+ sections = [s for s, _ in sections if s]
72
+ for (_, html), _ in tbls:
73
+ sections.append(html)
74
  callback(0.8, "Finish parsing.")
75
 
76
  elif re.search(r"\.pdf$", filename, re.IGNORECASE):