Conversation
|
Warning Rate limit exceeded
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 44 minutes and 49 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughFuzzyAttributeParser adds regex-based OCR normalization, fuzzy categorical matching, and refined id/number cleaning. YoloToXmlConverter refactors layout generation: scales widgets, assigns OCR text boxes to parents, derives canvas tags, matches annotations to elements, and extracts attribute-emission into new helpers. Changes
Sequence DiagramsequenceDiagram
participant Converter as YoloToXmlConverter
participant Scaler as Scaler
participant TextAssigner as TextAssigner
participant TagDeriver as TagDeriver
participant Matcher as AnnotationMatcher
participant Builder as XmlBuilder
participant Parser as FuzzyAttributeParser
Converter->>Scaler: Scale YOLO widget boxes (exclude widget_tag)
Scaler-->>Converter: scaledBoxes
Converter->>TextAssigner: assignTextToParents(scaledBoxes, ocrBoxes)
TextAssigner-->>Converter: parentTextMappings
Converter->>TagDeriver: derive canvas tags (widget_tag + OCR tag text)
TagDeriver-->>Converter: canvasTags
Converter->>Matcher: matchAnnotationsToElements(canvasTags, scaledBoxes, parentTextMappings)
Matcher-->>Converter: finalAnnotations
Converter->>Builder: build XML from sortedBoxes + finalAnnotations
Builder->>Parser: sanitize/normalize attribute values
Parser-->>Builder: cleanedAttributes
Builder-->>Converter: xmlLayout
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt (1)
490-492: Consider usingkotlin.random.Randomfor more idiomatic Kotlin.
Math.random()works butkotlin.random.Random.nextInt(1000)is more idiomatic and explicit about the integer range.♻️ Suggested improvement
+import kotlin.random.Random + // In cleanId function: - return "view_${(Math.random() * 1000).toInt()}" + return "view_${Random.nextInt(1000)}"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt` around lines 490 - 492, Replace the use of Math.random() in the FuzzyAttributeParser return expression with the idiomatic Kotlin random integer API: use kotlin.random.Random.nextInt(1000) to generate the 0–999 int and construct the ID string (i.e., change the expression inside the if in FuzzyAttributeParser where it returns "view_${(Math.random() * 1000).toInt()}" to use Random.nextInt(1000)); add an import for kotlin.random.Random if required.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/FuzzyAttributeParser.kt`:
- Around line 490-492: Replace the use of Math.random() in the
FuzzyAttributeParser return expression with the idiomatic Kotlin random integer
API: use kotlin.random.Random.nextInt(1000) to generate the 0–999 int and
construct the ID string (i.e., change the expression inside the if in
FuzzyAttributeParser where it returns "view_${(Math.random() * 1000).toInt()}"
to use Random.nextInt(1000)); add an import for kotlin.random.Random if
required.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d745e406-afeb-4484-9b73-4ee1ef882fd6
📒 Files selected for processing (2)
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.kt
bc85cf0 to
5727d0d
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/FuzzyAttributeParser.kt`:
- Line 152: The regex ocrLetterBToSixRegex incorrectly maps OCR 'B' to the digit
6; update the mapping and its name to reflect that 'B' is visually confused with
'8' (e.g., rename to ocrLetterBToEightRegex and keep the pattern Regex("[bB]")),
and then update all usages in extractOcrNumber to replace the old mapping
logic/name so the parser substitutes 'B' -> '8' instead of '6'.
- Around line 475-477: The fallback ID generation in FuzzyAttributeParser (the
block checking FuzzySearch.ratio for "match_parent"/"wrap_content") is
non-deterministic and low-cardinality; replace the Math.random() usage with a
thread-safe incremental counter (e.g., an AtomicInteger field in the class) and
produce IDs like "view_${counter.incrementAndGet()}" to ensure deterministic,
unique IDs and avoid test flakiness and collisions.
- Around line 502-511: The extractOcrNumber function currently normalizes the
entire input string (using ocrLetterOToZeroRegex, ocrLetterIToOneRegex,
ocrLetterZToTwoRegex, ocrLetterSToFiveRegex, ocrLetterBToSixRegex) which
corrupts unit suffixes like "sp"/"dp"; change the logic to detect and strip any
trailing unit suffix before normalization (e.g., check for common units such as
"sp", "dp", "px"), apply the regex replacements only to the stripped numeric
part, run numberExtractionRegex on that normalized numeric substring, and then
reattach/return the numeric value (or use it downstream) without having altered
the original unit suffix; update extractOcrNumber to operate on numericPart and
leave unitPart untouched.
🪄 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: 1f8c18e6-85e4-44d2-a113-07314d69b577
📒 Files selected for processing (2)
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.kt
🚧 Files skipped from review as they are similar to previous changes (1)
- cv-image-to-xml/src/main/java/org/appdevforall/codeonthego/computervision/domain/YoloToXmlConverter.kt
f04ef0f to
5ba557d
Compare
|
The PR description images show:
Would you like me to proceed with a full review, or is there something specific you'd like me to look at? 🧠 Learnings used✅ Actions performedReview triggered.
|
6ad9ed5 to
f4995f8
Compare
f869f7c to
8e2974f
Compare
Add regex-based typo sanitization and extract XML view generation into dedicated functions.
Rely entirely on the existing escapeXmlAttr method for XML safety and drop hardcoded OCR typo fixes.
…fy dimension keyword matching
8e2974f to
eb6b697
Compare
Description
This PR improves the accuracy and maintainability of the computer vision to XML pipeline.
FuzzyAttributeParserto include comprehensive regex-based sanitization for common OCR typos (e.g., misreading '0' as 'o', '5' as 's') and common UI label typos (e.g., "usemame" to "Username").inputType,gravity, andtextStyleto ensure valid Android XML output.YoloToXmlConverterto reduce cyclomatic complexity. The large mapping and appending logic was broken down into smaller, specialized functions (assignTextToParents,matchAnnotationsToElements,appendTextViewAttributes, etc.).Details
Logic-related changes. Verified parsing improvements and corrected UI typo mappings via application logs. XML generation now cleanly delegates to component-specific builder methods.
Ticket
ADFA-3709