ADFA-3912 | Fix fuzzy attribute parsing bounds and UI element tag filtering#1275
ADFA-3912 | Fix fuzzy attribute parsing bounds and UI element tag filtering#1275
Conversation
📝 WalkthroughRelease Notes - ADFA-3912 | Fix fuzzy attribute parsing bounds and UI element tag filteringFeatures & Fixes
Implementation Details
Dependencies & Integration
Risks & Considerations
WalkthroughThe pull request refactors the XML generation pipeline in YoloToXmlConverter by extracting inline steps into private helper functions, adds a validation guard in FuzzyAttributeParser to prevent invalid substring extraction, and introduces a new extension function for building placeholder overrides. ChangesAttribute Parsing Validation Guard
XML Generation Pipeline Refactoring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
48bb962 to
35ac06e
Compare
Added bounds validation in FuzzyAttributeParser and updated UI element filter logic.
35ac06e to
efe479f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/YoloToXmlConverter.kt`:
- Around line 87-95: In associateTextToWidgets change the parent selection so
you do not drop non-text boxes based on annotationMatcher.isTag: keep parents as
all boxes where it.label != "text" (remove the isTag check), while still
filtering initialTexts with annotationMatcher.isTag so only text boxes get
tag-filtered; then call geometryProcessor.assignTextToParents(parents,
initialTexts, scaledBoxes) and proceed with the existing remainingTexts and
geometryProcessor.assignNearbyTextToWidgets call unchanged (references:
associateTextToWidgets, annotationMatcher.isTag,
geometryProcessor.assignTextToParents,
geometryProcessor.assignNearbyTextToWidgets).
🪄 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: b21178be-4d63-4592-b3a7-27fcbba14f63
📒 Files selected for processing (3)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/YoloToXmlConverter.ktcv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/utils/PlaceholderUtils.kt
| private fun associateTextToWidgets(scaledBoxes: List<ScaledBox>): List<ScaledBox> { | ||
| val parents = scaledBoxes.filter { it.label != "text" && !annotationMatcher.isTag(it.text) } | ||
| val initialTexts = scaledBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | ||
|
|
||
| val textAssignedBoxes = geometryProcessor.assignTextToParents(parents, initialTexts, scaledBoxes) | ||
|
|
||
| val remainingTexts = textAssignedBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | ||
| return geometryProcessor.assignNearbyTextToWidgets(textAssignedBoxes, remainingTexts) | ||
| } |
There was a problem hiding this comment.
Restrict tag filtering to text boxes here too.
Line 88 still excludes any non-text box whose OCR text looks like a tag. That can drop valid widgets before text association, so the tag-filtering bug is still partially present despite the later fix in finalizeUiElements.
Suggested fix
private fun associateTextToWidgets(scaledBoxes: List<ScaledBox>): List<ScaledBox> {
- val parents = scaledBoxes.filter { it.label != "text" && !annotationMatcher.isTag(it.text) }
+ val parents = scaledBoxes.filter { it.label != "text" }
val initialTexts = scaledBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) }
val textAssignedBoxes = geometryProcessor.assignTextToParents(parents, initialTexts, scaledBoxes)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| private fun associateTextToWidgets(scaledBoxes: List<ScaledBox>): List<ScaledBox> { | |
| val parents = scaledBoxes.filter { it.label != "text" && !annotationMatcher.isTag(it.text) } | |
| val initialTexts = scaledBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | |
| val textAssignedBoxes = geometryProcessor.assignTextToParents(parents, initialTexts, scaledBoxes) | |
| val remainingTexts = textAssignedBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | |
| return geometryProcessor.assignNearbyTextToWidgets(textAssignedBoxes, remainingTexts) | |
| } | |
| private fun associateTextToWidgets(scaledBoxes: List<ScaledBox>): List<ScaledBox> { | |
| val parents = scaledBoxes.filter { it.label != "text" } | |
| val initialTexts = scaledBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | |
| val textAssignedBoxes = geometryProcessor.assignTextToParents(parents, initialTexts, scaledBoxes) | |
| val remainingTexts = textAssignedBoxes.filter { it.label == "text" && !annotationMatcher.isTag(it.text) } | |
| return geometryProcessor.assignNearbyTextToWidgets(textAssignedBoxes, remainingTexts) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/YoloToXmlConverter.kt`
around lines 87 - 95, In associateTextToWidgets change the parent selection so
you do not drop non-text boxes based on annotationMatcher.isTag: keep parents as
all boxes where it.label != "text" (remove the isTag check), while still
filtering initialTexts with annotationMatcher.isTag so only text boxes get
tag-filtered; then call geometryProcessor.assignTextToParents(parents,
initialTexts, scaledBoxes) and proceed with the existing remainingTexts and
geometryProcessor.assignNearbyTextToWidgets call unchanged (references:
associateTextToWidgets, annotationMatcher.isTag,
geometryProcessor.assignTextToParents,
geometryProcessor.assignNearbyTextToWidgets).
Description
Fixed an out-of-bounds string extraction error in
FuzzyAttributeParserby adding a safeguard check (current.valueStart > valueEnd) before processing annotations. Additionally, updated the UI element filtering logic inYoloToXmlConverterso that theisTagexclusion only applies to elements explicitly labeled as "text". This ensures valid UI elements are not improperly excluded during conversion.Details
document_5179472272527722523.mp4
Ticket
ADFA-3912
Observation