Skip to content

OCR related defect fix#4343

Merged
Maheshkale447 merged 1 commit into
Releases/Official-Releasefrom
BugFix/OCRReletaed
Oct 17, 2025
Merged

OCR related defect fix#4343
Maheshkale447 merged 1 commit into
Releases/Official-Releasefrom
BugFix/OCRReletaed

Conversation

@AmanPrasad43

@AmanPrasad43 AmanPrasad43 commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Before submitting this PR, please make sure:

  • PR description and commit message should describe the changes done in this PR
  • Verify the PR is pointing to correct branch i.e. Release or Beta branch if the code fix is for specific release , else point it to master
  • Latest Code from master or specific release branch is merged to your branch
  • No unwanted\commented\junk code is included
  • No new warning upon build solution
  • Code Summary\Comments are added to my code which explains what my code is doing
  • Existing unit test cases are passed
  • New Unit tests are added for your development
  • Sanity Tests are successfully executed for New and Existing Functionality
  • Verify that changes are compatible with all relevant browsers and platforms.
  • After creating pull request there should not be any conflicts
  • Resolve all Codacy comments
  • Builds and checks are passed before PR is sent for review
  • Resolve code review comments
  • Update the Help Library document to match any feature changes

Summary by CodeRabbit

Bug Fixes

  • Improved OCR text extraction when reading content across multiple lines—now properly spaces text and applies case-insensitive marker matching.
  • Fixed text formatting to remove excess whitespace from extracted content.

@coderabbitai

coderabbitai Bot commented Oct 17, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Modified ReadTextBetweenTwoLabels in GingerOcrOperations.cs to improve text extraction between labels. Changes include adding spaces between text regions, implementing case-insensitive label matching, and trimming final output whitespace.

Changes

Cohort / File(s) Summary
OCR Text Extraction Enhancement
Ginger/GingerCore/GingerOCR/GingerOcrOperations.cs
Updated ReadTextBetweenTwoLabels method: adds space after first region text when second label not found on same line, applies case-insensitive comparison for second label search, appends space after current line text in subsequent iterations, and trims whitespace from final result

Sequence Diagram(s)

sequenceDiagram
    participant Method as ReadTextBetweenTwoLabels
    participant Text as Text Content
    participant Result as Result Builder

    Method->>Text: Find first label
    alt First label found
        Method->>Result: Append first region text
        Note over Method,Result: NEW: Add space after first region
        Method->>Text: Search for second label (next line)
        alt Second label found
            Method->>Result: Return accumulated text
        else Second label not found
            Note over Method: NEW: Case-insensitive comparison
            Method->>Result: Append current line + space
            Method->>Text: Continue to next line
            Method->>Text: Search for second label again
        end
    end
    Method->>Result: NEW: Trim whitespace
    Method->>Method: Return trimmed result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • Maheshkale447

Poem

🐰 A rabbit hops through text so fine,
Finding labels, line by line,
With spaces placed and cases ignored,
Trimmed and true—the text restored!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is entirely composed of the unchecked template checklist with no additional content. The author has not provided any actual description of the changes made, leaving all checkbox items unchecked and providing no explanation of the OCR defect being fixed or the specific modifications to GingerOcrOperations.cs. The first checklist item explicitly requires "PR description and commit message should describe the changes done in this PR," which has not been fulfilled. The author must add a substantive PR description explaining the defect that was fixed, the specific changes made to the ReadTextBetweenTwoLabels method (spacing, case-insensitive comparison, result trimming), and the rationale for these changes. Additionally, the author should check off the template items that have been completed to indicate their PR is ready for review.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title Check ❓ Inconclusive The title "OCR related defect fix" is vague and generic, using non-descriptive terms that fail to convey specific information about the changeset. While the title is technically related to the actual changes (which do involve OCR bug fixes in ReadTextBetweenTwoLabels), it provides no meaningful detail about what specific defect was addressed or what behavior was modified. A teammate scanning the repository history would have no way to understand the nature of this fix from the title alone.
✨ 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 BugFix/OCRReletaed

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cc944e8 and 87919e8.

📒 Files selected for processing (1)
  • Ginger/GingerCore/GingerOCR/GingerOcrOperations.cs (3 hunks)
🔇 Additional comments (4)
Ginger/GingerCore/GingerOCR/GingerOcrOperations.cs (4)

208-210: Good fix for preventing word concatenation.

Adding a space between regions prevents words from incorrectly concatenating when the second label is not found on the same line as the first label. The final Trim() will handle any excess trailing whitespace.


215-215: Good consistency fix, but consider updating the PDF method as well.

Making the second label search case-insensitive correctly matches the behavior of the first label search (line 195) and the same-line second label search (line 199). However, the similar method ReadTextBetweenLabelsPdf (lines 377-438) still uses case-sensitive searches on lines 399, 403, and 417, creating an inconsistency between image and PDF OCR operations.

Consider updating ReadTextBetweenLabelsPdf to also use case-insensitive searches for consistency:

-                                int idx1 = lineTxt.IndexOf(firstLabel);
+                                int idx1 = lineTxt.IndexOf(firstLabel, StringComparison.OrdinalIgnoreCase);
                                 if (idx1 != -1)
                                 {
                                     started = true;
-                                    int idx2 = lineTxt.IndexOf(secondLabel, idx1 + firstLabel.Length);
+                                    int idx2 = lineTxt.IndexOf(secondLabel, idx1 + firstLabel.Length, StringComparison.OrdinalIgnoreCase);
                                     if (idx2 != -1)
                                     {

And:

                             else
                             {
-                                int idx2 = lineTxt.IndexOf(secondLabel);
+                                int idx2 = lineTxt.IndexOf(secondLabel, StringComparison.OrdinalIgnoreCase);
                                 if (idx2 != -1)

223-225: Good fix for preventing word concatenation across regions.

Adding a space after each region ensures proper word separation when text spans multiple OCR regions. This is consistent with the similar change on line 209.


235-235: Good practice to trim the final output.

Trimming the result removes any leading or trailing whitespace, including excess spaces that may have been added during region concatenation. This ensures clean output.


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.

@Maheshkale447
Maheshkale447 merged commit cf80fde into Releases/Official-Release Oct 17, 2025
10 of 15 checks passed
@Maheshkale447
Maheshkale447 deleted the BugFix/OCRReletaed branch October 17, 2025 14:04
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.

2 participants