feat: Add fuzzy matching to VIN decode for partial model/trim names (refs #9)
Some checks failed
Deploy to Staging / Build Images (pull_request) Failing after 3m1s
Deploy to Staging / Deploy to Staging (pull_request) Has been skipped
Deploy to Staging / Verify Staging (pull_request) Has been skipped
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
Some checks failed
Deploy to Staging / Build Images (pull_request) Failing after 3m1s
Deploy to Staging / Deploy to Staging (pull_request) Has been skipped
Deploy to Staging / Verify Staging (pull_request) Has been skipped
Deploy to Staging / Notify Staging Ready (pull_request) Has been skipped
Deploy to Staging / Notify Staging Failure (pull_request) Successful in 6s
Backend: Enhanced matchField function with prefix and contains matching so NHTSA values like "Sierra" match dropdown options like "Sierra 1500". Matching hierarchy: 1. Exact match (case-insensitive) -> high confidence 2. Normalized match (remove special chars) -> medium confidence 3. Prefix match (option starts with value) -> medium confidence (NEW) 4. Contains match (option contains value) -> medium confidence (NEW) Frontend: Fixed VIN decode form population by loading dropdown options before setting form values, preventing cascade useEffects from clearing decoded values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -441,8 +441,9 @@ export class VehiclesService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Match a value against dropdown options using case-insensitive exact matching
|
||||
* Match a value against dropdown options using fuzzy matching
|
||||
* Returns the matched dropdown value with confidence level
|
||||
* Matching order: exact -> normalized -> prefix -> contains
|
||||
*/
|
||||
private matchField(nhtsaValue: string, options: string[]): MatchedField<string> {
|
||||
if (!nhtsaValue || options.length === 0) {
|
||||
@@ -466,6 +467,18 @@ export class VehiclesService {
|
||||
return { value: normalizedMatch, nhtsaValue, confidence: 'medium' };
|
||||
}
|
||||
|
||||
// Try prefix match - option starts with NHTSA value
|
||||
const prefixMatch = options.find(opt => opt.toLowerCase().trim().startsWith(normalizedNhtsa));
|
||||
if (prefixMatch) {
|
||||
return { value: prefixMatch, nhtsaValue, confidence: 'medium' };
|
||||
}
|
||||
|
||||
// Try contains match - option contains NHTSA value
|
||||
const containsMatch = options.find(opt => opt.toLowerCase().trim().includes(normalizedNhtsa));
|
||||
if (containsMatch) {
|
||||
return { value: containsMatch, nhtsaValue, confidence: 'medium' };
|
||||
}
|
||||
|
||||
// No match found - return NHTSA value as hint with no match
|
||||
return { value: null, nhtsaValue, confidence: 'none' };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user