mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix parser_config access for layout_recognize in presentation.py (#8492)
### What problem does this PR solve?
This PR addresses an issue in the presentation parser where the
`layout_recognize` configuration was incorrectly retrieved from
`kwargs.get("layout_recognize", "DeepDOC")`. Instead, it should be
sourced from the `parser_config` parameter, specifically
`parser_config.get("layout_recognize", "DeepDOC")`.
This mismatch could cause the parser to default to the "DeepDOC" layout
recognizer, ignoring any alternative recognition method specified in the
parser configuration. As a result, PDF document parsing might use an
incorrect recognition engine.
The fix ensures the presentation parser consistently uses the
`layout_recognize` setting from `parser_config`, aligning with the
configuration access patterns used elsewhere in the codebase.
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -98,12 +98,14 @@ class PlainPdf(PlainParser):
|
|||||||
|
|
||||||
|
|
||||||
def chunk(filename, binary=None, from_page=0, to_page=100000,
|
def chunk(filename, binary=None, from_page=0, to_page=100000,
|
||||||
lang="Chinese", callback=None, **kwargs):
|
lang="Chinese", callback=None, parser_config=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
The supported file formats are pdf, pptx.
|
The supported file formats are pdf, pptx.
|
||||||
Every page will be treated as a chunk. And the thumbnail of every page will be stored.
|
Every page will be treated as a chunk. And the thumbnail of every page will be stored.
|
||||||
PPT file will be parsed by using this method automatically, setting-up for every PPT file is not necessary.
|
PPT file will be parsed by using this method automatically, setting-up for every PPT file is not necessary.
|
||||||
"""
|
"""
|
||||||
|
if parser_config is None:
|
||||||
|
parser_config = {}
|
||||||
eng = lang.lower() == "english"
|
eng = lang.lower() == "english"
|
||||||
doc = {
|
doc = {
|
||||||
"docnm_kwd": filename,
|
"docnm_kwd": filename,
|
||||||
@ -126,7 +128,7 @@ def chunk(filename, binary=None, from_page=0, to_page=100000,
|
|||||||
res.append(d)
|
res.append(d)
|
||||||
return res
|
return res
|
||||||
elif re.search(r"\.pdf$", filename, re.IGNORECASE):
|
elif re.search(r"\.pdf$", filename, re.IGNORECASE):
|
||||||
layout_recognizer = kwargs.get("layout_recognize", "DeepDOC")
|
layout_recognizer = parser_config.get("layout_recognize", "DeepDOC")
|
||||||
if layout_recognizer == "DeepDOC":
|
if layout_recognizer == "DeepDOC":
|
||||||
pdf_parser = Pdf()
|
pdf_parser = Pdf()
|
||||||
sections = pdf_parser(filename, binary, from_page=from_page, to_page=to_page, callback=callback)
|
sections = pdf_parser(filename, binary, from_page=from_page, to_page=to_page, callback=callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user