Improve scanner repeatability guardrails
This commit is contained in:
@@ -178,6 +178,9 @@ function parseArtifactName(titleText: string): ParsedField {
|
||||
if (alias) return field(alias, 96, "database");
|
||||
}
|
||||
|
||||
const partialPiece = derivePieceFromDistinctivePartialName(titleText);
|
||||
if (partialPiece) return field(partialPiece, 72, "fallback");
|
||||
|
||||
const knownPiece = fuzzyFindKnown(titleText, knownPieceNames, 0.72);
|
||||
if (knownPiece) return field(knownPiece.value, Math.round(knownPiece.score * 100), knownPiece.score >= 0.98 ? "database" : "fallback");
|
||||
|
||||
@@ -294,6 +297,20 @@ function deriveSetFromPartialPieceName(text: string) {
|
||||
return sets.length === 1 ? sets[0] : "";
|
||||
}
|
||||
|
||||
function derivePieceFromDistinctivePartialName(text: string) {
|
||||
const words = cleanupOcrLabel(text)
|
||||
.split(/\s+/)
|
||||
.map((word) => simplifyForMatch(word))
|
||||
.filter((word) => word.length >= 8);
|
||||
if (words.length === 0) return "";
|
||||
|
||||
const candidates = knownPieceNames.filter((piece) => {
|
||||
const normalizedPiece = simplifyForMatch(piece);
|
||||
return words.some((word) => normalizedPiece.includes(word));
|
||||
});
|
||||
return candidates.length === 1 ? candidates[0] : "";
|
||||
}
|
||||
|
||||
function findMainValue(text: string, mainStat: string, slot: string, level: number | null): ParsedField {
|
||||
const cleaned = text.replace(/\b20\b/g, " ").replace(/[Oo]/g, "0");
|
||||
const percentValue = extractPercentValue(cleaned);
|
||||
|
||||
Reference in New Issue
Block a user