Skip to content

Fix pdfoxide parser smashed text issues - #22

Open
rager306 wants to merge 1 commit into
mainfrom
fix-pdfoxide-preprocessing-16596587119210642408
Open

Fix pdfoxide parser smashed text issues#22
rager306 wants to merge 1 commit into
mainfrom
fix-pdfoxide-preprocessing-16596587119210642408

Conversation

@rager306

@rager306 rager306 commented Jan 28, 2026

Copy link
Copy Markdown
Owner

Implemented preprocess_text in pdfparser/pdfoxide_parser.py to resolve issue where pdf_oxide extraction merges consecutive currency amounts. The fix inserts newlines between smashed amounts to restore the line-based structure expected by extract_transactions. Added comprehensive tests to verify the fix.


PR created automatically by Jules for task 16596587119210642408 started by @rager306

Summary by CodeRabbit

  • New Features

    • Enhanced PDF parsing to automatically detect and separate improperly merged currency amounts in extracted text.
  • Tests

    • Added comprehensive unit tests for the new text preprocessing functionality, including edge cases with thousands separators and multiline inputs.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add `preprocess_text` function to `pdfparser/pdfoxide_parser.py` to fix smashed currency amounts (e.g., `0.0026,000.00` -> `0.00\n26,000.00`).
- Use double-pass regex substitution to handle chained smashed amounts.
- Update `parse_pdf_pdfoxide` to invoke `preprocess_text` on extracted text.
- Add unit tests in `tests/test_pdfoxide_preprocessing.py`.

Co-authored-by: rager306 <248269686+rager306@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jan 28, 2026

Copy link
Copy Markdown

Walkthrough

A new preprocess_text function was added to handle PDF text extraction artifacts by using regular expression substitution to separate smashed currency amounts. The function is called on aggregated page text before transaction extraction, with module-level re import added to support this preprocessing.

Changes

Cohort / File(s) Summary
Core implementation
pdfparser/pdfoxide_parser.py
Added top-level preprocess_text(text: str) -> str function implementing two-pass regex substitution to separate smashed monetary values (e.g., consecutive currency amounts on same line). Module-level re import added. Function called in parse_pdf_pdfoxide on aggregated text before extraction. Removed local in-function import of re.
Tests
tests/test_pdfoxide_preprocessing.py
New test module with 5 unit tests covering: simple smashed amount splitting, multiple consecutive amounts, amounts with commas/separators, unchanged properly-formatted text, and multiline input handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and specifically addresses the main change: fixing the pdfoxide parser's handling of smashed text artifacts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-pdfoxide-preprocessing-16596587119210642408

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant