Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ def _parse(self, doc: DoclingDocument):

def _get_current_level(self, parents):
for k, v in parents.items():
if v == None and k > 0:
if v is None and k > 0:
return k - 1

return 0

def _get_current_parent(self, parents):
for k, v in parents.items():
if v == None and k > 0:
if v is None and k > 0:
return parents[k - 1]

return None
Expand Down Expand Up @@ -328,15 +328,15 @@ def _parse_list_item(self, line):
"marker": marker,
"text": text.strip(),
"numbered": False,
"indent": 0 if indent == None else len(indent),
"indent": 0 if indent is None else len(indent),
}
else:
return {
"type": "list_item",
"marker": marker,
"text": text.strip(),
"numbered": True,
"indent": 0 if indent == None else len(indent),
"indent": 0 if indent is None else len(indent),
}
else:
# Fallback if no match
Expand Down
4 changes: 2 additions & 2 deletions src/evaluation/PresentQuiz/docling/backend/html_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def extract_text_recursively(self, item: Tag):
try:
# Recursively get the child's text content
result.extend(self.extract_text_recursively(child))
except:
except Exception:
pass
except:
except Exception:
_log.warn("item has no children")
pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def _find_images_in_sheet(
image=ImageRef.from_pil(image=pil_image, dpi=72),
caption=None,
)
except:
except Exception:
_log.error("could not extract the image from excel sheets")

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def prev_indent(self) -> Optional[int]:
def get_level(self) -> int:
"""Return the first None index."""
for k, v in self.parents.items():
if k >= 0 and v == None:
if k >= 0 and v is None:
return k
return 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, enabled: bool, options: TesseractOcrOptions):
raise ImportError(install_errmsg)
try:
tesseract_version = tesserocr.tesseract_version()
except:
except Exception:
raise ImportError(install_errmsg)

_, self._tesserocr_languages = tesserocr.get_languages()
Expand Down
2 changes: 1 addition & 1 deletion src/evaluation/PresentQuiz/docling/utils/glm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def resolve_item(paths, obj):

try:
key = int(paths[0])
except:
except Exception:
key = paths[0]

if len(paths) == 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def generate(model: Literal["Qwen2.5", "gpt"]):
progress = tqdm(total=len(folders))

def process_folder(pdf_folder, model, processor):
source_text = open(f"{pdf_folder}/source.md").read()
with open(f"{pdf_folder}/source.md") as f:
source_text = f.read()
bird_eye = json.load(open(f"{pdf_folder}/refined_doc.json"))
images = json.load(open(f"{pdf_folder}/image_caption.json")).keys()
output_dir = f"{pdf_folder}/docpres/{llm_name}"
Expand Down