Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions deepdoc/parser/docx_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def blockType(b):
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
Expand All @@ -130,7 +130,7 @@ def __call__(self, fnm, from_page=0, to_page=100000):
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