Skip to content

fix(normalizer): năm is a duration only at the end; a bare size equal to the gift's keeps it - #1334

Open
JOY (JOY) wants to merge 1 commit into
devfrom
fix/1333-nam-year-forms
Open

JOY (JOY) wants to merge 1 commit into
devfrom
fix/1333-nam-year-forms

Conversation

@JOY

@JOY JOY (JOY) commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1333

Follow-up to #1317 (PR #1321).

What (product-normalizer.ts)

  • P2 / P3: "năm" after a bare size counts as a duration only when it ends the title or comes before a separator (13 năm, 13 năm, ...). Any word or year form after it keeps the size: "năm sx 2022", "năm sản xuất 2022", "năm ra mắt 2022", "năm: 2022", "năm 22", "11 năm bảo hành". A screen size (10 to 16) is never a warranty in years, so the year lookahead (and its unbounded "20243") is gone.
  • P3: a bare size equal to the gift's only size no longer blocks the gift fallback: "Series 10 tặng ốp 42mm 42 GPS" keys 42mm. A bare size that differs from the gift's still blocks it ("GPS 46 tặng ốp 42mm" stays size-less).

Before/after keys

Over every string literal mentioning Watch/iPad/MacBook in apps/importer/src, packages, apps/web/e2e and supabase (562 strings, new fixtures included), origin/dev vs this branch: 7 changed, all fixtures of this issue:

  • "iPad Pro 11 năm sx 2022", "iPad Pro 11 năm: 2022", "iPad Pro 11 năm 22" -> -11; "iPad Pro 12.9 năm sản xuất 2022" -> -129; "MacBook Air 13 năm ra mắt 2022" -> -13
  • "iPad Pro M4 256GB 11 năm bảo hành tặng ốp 13 inch": -13 -> -11
  • "Apple Watch Series 10 tặng ốp 42mm 42 GPS": no size -> -42mm

#1263 / #1277 / #1291 / #1317 fixtures unchanged ("MacBook Air M2 13 năm" stays size-less).

Checks

pnpm --filter @repo/crawlers test, typecheck, lint, prettier: green locally.

🤖 Generated with Claude Code


📌 TL;DR

Refines the Shopee product normalizer's size extraction logic to correctly handle Vietnamese "year" tokens (e.g., "năm 2022") and bare size matches, preventing false positives where production years or duplicate gift sizes are misidentified as device dimensions.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/importer/src/shopee/__tests__/open-core-intelligence.test.ts Adds test cases verifying that "năm" (year) followed by various formats (e.g., "sx 2022", "22", "bảo hành") is not parsed as a size, and that a bare size matching the gift size is correctly ignored.
apps/importer/src/shopee/product-normalizer.ts 1. Updates the SIZE_NOT_FOLLOWED_BY regex to exclude "năm" (year) from being treated as a size suffix unless followed by specific delimiters.
2. Refactors readAppleSize to introduce a namesOtherBare helper. This ensures that if a bare size is found in the product title, it is only considered valid if it differs from the gift's size, preventing the gift's size from overriding the product's actual size when they match.

📊 Architectural Flow

flowchart TD
    A[Raw Product Title] --> B[Extract Gift Sizes]
    B --> C{Gift Size Count == 1?}
    C -->|No| D[Return Empty / Default]
    C -->|Yes| E[Identify Gift Size]
    E --> F[Scan Product Part for Sizes]
    F --> G{Found Bare Size?}
    G -->|No| H[Check Standard Patterns]
    G -->|Yes| I{Bare Size != Gift Size?}
    I -->|No| J[Ignore Bare Size]
    I -->|Yes| K[Accept Bare Size]
    H --> L[Validate Against Regex Rules]
    L --> M{Is 'nam' followed by year/delimiter?}
    M -->|Yes| N[Exclude from Size Match]
    M -->|No| O[Include in Size Match]
    J --> P[Final Size Resolution]
    K --> P
    N --> P
    O --> P
    P --> Q[Normalized Product Object]
Loading

…al to the gift's keeps it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Oct 29, 2026 1:20am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26aadd0e-8822-4c77-a8ce-9fb29fd54643
Commits

Reviewing files that changed from the base of the PR and between 40ddb30 and 394c969.

Files selected for processing: 2
  • apps/importer/src/shopee/__tests__/open-core-intelligence.test.ts
  • apps/importer/src/shopee/product-normalizer.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

dos[bot]
dos Bot approved these changes Oct 29, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏱️ Code Review completed (2 eligible files · 4,480 chars · 3 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base 40ddb30 / head 394c969.

✅ CLEAN_PASS: Complete diff reviewed

Context investigation was bounded to the explicitly requested snapshot paths.

This branch was successfully deployed

1 active deployment
Preview — 394c969b Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(normalizer): năm followed by sx, ra mắt or a short year still drops the size

1 participant