Reclassify 4.A.05.A0008 as special servo
This commit is contained in:
@@ -26,6 +26,11 @@ CATEGORY_BY_PAGE = {
|
||||
**{page: "翻盖电机" for page in range(28, 30)},
|
||||
}
|
||||
|
||||
# Business categories can intentionally differ from the source page heading.
|
||||
CATEGORY_BY_CODE = {
|
||||
"4.A.05.A0008": "异形舵机",
|
||||
}
|
||||
|
||||
SPEC_LABELS = {
|
||||
"标准舵机": [
|
||||
"产品尺寸", "最大砝码负载", "堵转扭矩", "空载速度", "可操作角度",
|
||||
@@ -141,9 +146,9 @@ def main() -> None:
|
||||
|
||||
with pdfplumber.open(PDF_PATH) as pdf:
|
||||
for page_number, page in enumerate(pdf.pages, 1):
|
||||
category = CATEGORY_BY_PAGE[page_number]
|
||||
page_category = CATEGORY_BY_PAGE[page_number]
|
||||
page_text = clean(page.extract_text() or "")
|
||||
expected_heading = f"{category}产品明细表"
|
||||
expected_heading = f"{page_category}产品明细表"
|
||||
if expected_heading not in page_text:
|
||||
raise RuntimeError(
|
||||
f"Category heading mismatch on page {page_number}: expected {expected_heading}"
|
||||
@@ -169,6 +174,7 @@ def main() -> None:
|
||||
code = clean_code(row[2])
|
||||
if not code or not re.search(r"[A-Z].*\d", code):
|
||||
continue
|
||||
category = CATEGORY_BY_CODE.get(code, page_category)
|
||||
|
||||
explicit_name = clean(row[1])
|
||||
if explicit_name:
|
||||
@@ -185,10 +191,10 @@ def main() -> None:
|
||||
crop_product_image(rendered, page.width, page.height, cell, IMAGE_DIR / image_name)
|
||||
inherited_image = f"/catalog-products/{image_name}"
|
||||
|
||||
values = normalize_spec_values(category, row, inherited_size)
|
||||
values = normalize_spec_values(page_category, row, inherited_size)
|
||||
specs = {
|
||||
label: value
|
||||
for label, value in zip(SPEC_LABELS[category], values)
|
||||
for label, value in zip(SPEC_LABELS[page_category], values)
|
||||
if value and value != "/"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user