Skip to content

ADFA-3755 | Fix Spinner entries OCR parsing and validation#1234

Merged
jatezzz merged 2 commits into
stagefrom
fix/ADFA-3755-add-entries-validator-experimental
Apr 23, 2026
Merged

ADFA-3755 | Fix Spinner entries OCR parsing and validation#1234
jatezzz merged 2 commits into
stagefrom
fix/ADFA-3755-add-entries-validator-experimental

Conversation

@jatezzz
Copy link
Copy Markdown
Collaborator

@jatezzz jatezzz commented Apr 22, 2026

Description

This PR fixes an issue where dropdown entries were being omitted from the generated XML and corrupted by OCR noise.

  • What: Added a custom EntriesValidator and updated SpinnerGrammar.
  • How: SpinnerGrammar now correctly maps to tools:entries instead of android:entries to prevent build errors with raw arrays. The new EntriesValidator processes the array elements individually, distinguishing between likely numbers and text. It cleans common OCR artifacts (like mistaking 'o' for '0' or 'l' for '1') in numeric data while safely preserving standard text strings and Android resource references (e.g., @array/items).
  • Why: To ensure the generated XML is fully compatible for developers without breaking project compilation, while accurately reflecting the user's sketched data.

Details

Logic update: Implemented regex-based sanitization for common OCR artifacts specifically targeted at numeric arrays, while preserving standard text words.

document_5136636871467599640.mp4

Ticket

ADFA-3755

Also fixes:
ADFA-3759

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@jatezzz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 50 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 50 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bbdc1ba-bd61-4a68-8663-d366e9b271fb

📥 Commits

Reviewing files that changed from the base of the PR and between a255ec2 and bba765d.

📒 Files selected for processing (1)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/AttributeValidator.kt
📝 Walkthrough

Walkthrough

A new EntriesValidator class is added to validate and normalize spinner entry attribute strings by processing bracket-enclosed comma-separated values, detecting garbled OCR numbers, collapsing whitespace, and rejoining normalized entries. The SpinnerGrammar is updated to use tools:entries with this new validator instead of android:entries with the previous pass-through validator.

Changes

Cohort / File(s) Summary
New Entries Validator
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/AttributeValidator.kt
Adds EntriesValidator that processes attribute values by: trimming whitespace, handling bracket-enclosed content, splitting by commas, normalizing garbled numbers (OCR noise mapped to digits with spaces removed) and general text (collapsed whitespace), then rejoining with ", " and re-wrapping brackets if present.
Grammar Configuration Update
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt
Updates SpinnerGrammar to replace the android:entries attribute key (with PassThroughValidator) to tools:entries (with EntriesValidator).

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested Reviewers

  • avestaadfa
  • Daniel-ADFA

Poem

🐰 Hop along with entries now refined,
Brackets parsed and commas aligned!
OCR noise becomes pristine,
The cleanest entries ever seen,
From @ pass-through to validation divine!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: fixing spinner entries OCR parsing and validation, which aligns with the addition of EntriesValidator and SpinnerGrammar updates.
Description check ✅ Passed The description is directly related to the changeset, explaining what was changed (EntriesValidator and SpinnerGrammar mapping), how it works, and why it matters for XML compatibility and OCR artifact handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ADFA-3755-add-entries-validator-experimental

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.

@jatezzz jatezzz requested review from a team, Daniel-ADFA and avestaadfa April 22, 2026 19:41
Update SpinnerGrammar to use tools namespace and parse array entries correctly.
@jatezzz jatezzz force-pushed the fix/ADFA-3755-add-entries-validator-experimental branch from 66907db to a255ec2 Compare April 22, 2026 20:33
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/AttributeValidator.kt`:
- Around line 63-97: The code fails to normalize OCR digits when the overall
attribute is a numeric list (e.g., "[0, l, 2]") because isOcrGarbledNumber
requires each item to already contain a real digit and cleanNumberArtifacts only
strips literal spaces; fix by detecting array-level numeric intent before
per-item processing and by normalizing whitespace removal: compute isNumericList
from content.split(",") (e.g., check tokens for any real digits or
OCR-digit-only tokens) and pass that flag into processItem (or map with
processItem(item, isNumericList)) so items like "l" are normalized; update
isOcrGarbledNumber to allow OCR-digit-only tokens when invoked in numeric-list
mode (or use the isNumericList flag instead of hasDigit), and change
cleanNumberArtifacts to remove all whitespace using Regex("\\s+") rather than
replacing only " ".
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 420d9264-3878-4325-a4e2-464645ae3dd5

📥 Commits

Reviewing files that changed from the base of the PR and between 363e581 and a255ec2.

📒 Files selected for processing (2)
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/AttributeValidator.kt
  • cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/grammar/WidgetGrammar.kt

@jatezzz jatezzz merged commit 3354b0c into stage Apr 23, 2026
2 checks passed
@jatezzz jatezzz deleted the fix/ADFA-3755-add-entries-validator-experimental branch April 23, 2026 15:35
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