Session 54: Audit cleanup — name edges + polish (2255 tests)
P1 name edge cases (BOTH playerName.js copies, kept identical): - normalizeName strips hyphens (display+key): "Jung-hoo Lee" === "Jung Hoo Lee". - nameKey strips single-letter MIDDLE tokens: "Josh H Smith" === "Josh Smith" (keeps first+last; real middle names + collapsed initials untouched). - richie -> richard added to NICKNAMES. P2 polish: - Team Hub names normalized at the source (teamService.getTeamHub) so "J.C. Escarra" renders as "JC Escarra" like the dashboard. - snapshotService dedup keeps the highest-confidence GRADE but the richest DISPLAY (accented "José" over "Jose") so prop rows match the pitcher line. - correlationWarning names the game: "2 legs from the same game (NYY @ BOS)". Backend 2246 -> 2255 tests (+9), 194 suites. Web build clean (exit 0). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,7 @@ const NICKNAMES = {
|
||||
jim: 'james', jimmy: 'james', ray: 'raymond', fred: 'frederick',
|
||||
kenny: 'kenneth', sam: 'samuel', pat: 'patrick', greg: 'gregory',
|
||||
steve: 'steven', tim: 'timothy', frank: 'francis', mickey: 'michael',
|
||||
richie: 'richard',
|
||||
};
|
||||
|
||||
// Collapse adjacent single-letter words: "J C Escarra" → "JC Escarra",
|
||||
@@ -50,6 +51,7 @@ function normalizeName(raw) {
|
||||
const display = collapseInitials(String(raw == null ? '' : raw)
|
||||
.replace(/\s*\([^)]*\)\s*/g, ' ') // strip parenthetical team tags "(STL)"
|
||||
.replace(/\./g, '') // strip dots: "A.J." → "AJ", "Jr." → "Jr"
|
||||
.replace(/-/g, ' ') // "Jung-hoo" → "Jung hoo" (matches "Jung Hoo")
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim());
|
||||
const folded = display.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
|
||||
@@ -63,8 +65,13 @@ function normalizeName(raw) {
|
||||
*/
|
||||
function nameKey(raw) {
|
||||
const { key } = normalizeName(raw);
|
||||
const parts = key.split(/\s+/).filter(Boolean);
|
||||
let parts = key.split(/\s+/).filter(Boolean);
|
||||
if (parts.length >= 2 && NICKNAMES[parts[0]]) parts[0] = NICKNAMES[parts[0]];
|
||||
// Strip single-letter MIDDLE tokens ("josh h smith" → "josh smith"); keep the
|
||||
// first (may be a collapsed initial like "jc") and last token.
|
||||
if (parts.length >= 3) {
|
||||
parts = parts.filter((p, i, arr) => i === 0 || i === arr.length - 1 || p.length > 1);
|
||||
}
|
||||
return parts.join(' ');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user