Skip to content

Commit cff705d

Browse files
committed
fix(ingest): preserve brand casing when synthesizing device names
When a Wikipedia row's model string omits the brand, name synthesis prefixed manufacturer.upper() / brand.title(), turning 'intel' into 'INTEL' (and 'oneplus' into 'Oneplus'). This reproduced the casing artifact that had to be fixed by hand in the data. Use explicit per-brand display forms so Intel stays 'Intel' while genuinely all-caps brands (AMD, NVIDIA) keep their casing.
1 parent f4ed0c2 commit cff705d

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

app/ingest/sources/wikipedia_cpu.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
("amd", "List_of_AMD_Threadripper_processors", "AMD Threadripper"),
4444
]
4545

46+
# Manufacturer keys are stored lowercase; these are their display forms used to
47+
# synthesize ``name`` when the model string omits the brand. Plain ``.upper()``
48+
# mangles "intel" → "INTEL" (an ingest casing artifact); AMD is genuinely
49+
# all-caps so it gets an explicit entry rather than title-casing.
50+
_BRAND_DISPLAY: dict[str, str] = {"intel": "Intel", "amd": "AMD"}
51+
4652
# Lowercased header tokens → canonical field name. Order matters: the first
4753
# matching fragment per cell wins (so a "Cores/Threads" column maps to
4854
# ``cores`` rather than ``threads``).
@@ -139,7 +145,8 @@ def _build_candidate(
139145
process_node = row.get("process_node") or None
140146

141147
segment = guess_cpu_segment(model)
142-
name = model if model.lower().startswith(manufacturer) else f"{manufacturer.upper()} {model}"
148+
brand = _BRAND_DISPLAY.get(manufacturer, manufacturer.title())
149+
name = model if model.lower().startswith(manufacturer) else f"{brand} {model}"
143150

144151
record: dict[str, object | None] = {
145152
"slug": slug,

app/ingest/sources/wikipedia_gpu.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
("intel", "List_of_Intel_graphics_processing_units", "Intel Graphics"),
3838
]
3939

40+
# Manufacturer keys are stored lowercase; these are their display forms used to
41+
# synthesize ``name`` when the model string omits the brand. Plain ``.upper()``
42+
# mangles "intel" → "INTEL" (an ingest casing artifact). NVIDIA and AMD are
43+
# genuinely all-caps so they get explicit entries rather than title-casing.
44+
_BRAND_DISPLAY: dict[str, str] = {"nvidia": "NVIDIA", "amd": "AMD", "intel": "Intel"}
45+
4046
# Same matching strategy as CPU but with GPU-specific keyword sets.
4147
HEADER_RULES: dict[str, list[str]] = {
4248
"model": ["model", "card", "name"],
@@ -127,7 +133,8 @@ def _build_candidate(
127133
memory_type = (row.get("memory_type") or "").upper() or None
128134

129135
segment = guess_gpu_segment(model)
130-
name = model if model.lower().startswith(manufacturer) else f"{manufacturer.upper()} {model}"
136+
brand = _BRAND_DISPLAY.get(manufacturer, manufacturer.title())
137+
name = model if model.lower().startswith(manufacturer) else f"{brand} {model}"
131138

132139
record: dict[str, object | None] = {
133140
"slug": slug,

app/ingest/sources/wikipedia_smartphone.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
("xiaomi", "List_of_Xiaomi_smartphones"),
3838
]
3939

40+
# Brand keys are stored lowercase; these are their display forms used to
41+
# synthesize ``name`` when the model string omits the brand. ``.title()`` is a
42+
# fine default (samsung→Samsung) but mangles intercapped brands, so those get
43+
# explicit entries (oneplus→OnePlus, not "Oneplus").
44+
_BRAND_DISPLAY: dict[str, str] = {"oneplus": "OnePlus"}
45+
4046
HEADER_RULES: dict[str, list[str]] = {
4147
"model": ["model", "name"],
4248
"release_date": ["released", "release", "launched", "launch", "date"],
@@ -163,7 +169,7 @@ def _build_candidate(
163169
name = (
164170
model
165171
if model.lower().startswith(brand) or model.lower().startswith(brand.upper())
166-
else f"{brand.title()} {model}"
172+
else f"{_BRAND_DISPLAY.get(brand, brand.title())} {model}"
167173
)
168174

169175
record: dict[str, object | None] = {

0 commit comments

Comments
 (0)