소스 검색

Fix:#3230 When parsing a docx file using the Book parsing method, to_page is always -1, resulting in a block count of 0 even if parsing is successful (#3249)

### What problem does this PR solve?

When parsing a docx file using the Book parsing method, to_page is
always -1, resulting in a block count of 0 even if parsing is successful

Fix:#3230

### Type of change

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

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
tags/v0.14.0
kuschzzp 11 달 전
부모
커밋
9c6cc20356
No account linked to committer's email address
2개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 1
    1
      api/db/db_models.py
  2. 2
    2
      deepdoc/parser/docx_parser.py

+ 1
- 1
api/db/db_models.py 파일 보기

@@ -840,7 +840,7 @@ class Task(DataBaseModel):
doc_id = CharField(max_length=32, null=False, index=True)
from_page = IntegerField(default=0)

to_page = IntegerField(default=-1)
to_page = IntegerField(default=100000000)

begin_at = DateTimeField(null=True, index=True)
process_duation = FloatField(default=0)

+ 2
- 2
deepdoc/parser/docx_parser.py 파일 보기

@@ -110,7 +110,7 @@ class RAGFlowDocxParser:
return lines
return ["\n".join(lines)]

def __call__(self, fnm, from_page=0, to_page=100000):
def __call__(self, fnm, from_page=0, to_page=100000000):
self.doc = Document(fnm) if isinstance(
fnm, str) else Document(BytesIO(fnm))
pn = 0 # parsed page
@@ -130,7 +130,7 @@ class RAGFlowDocxParser:
if 'lastRenderedPageBreak' in run._element.xml:
pn += 1

secs.append(("".join(runs_within_single_paragraph), p.style.name)) # then concat run.text as part of the paragraph
secs.append(("".join(runs_within_single_paragraph), p.style.name if hasattr(p.style, 'name') else '')) # then concat run.text as part of the paragraph

tbls = [self.__extract_table_content(tb) for tb in self.doc.tables]
return secs, tbls

Loading…
취소
저장