Reclassify 4.A.05.A0008 as special servo
This commit is contained in:
@@ -64,7 +64,7 @@ export const CATALOG_PRODUCTS: CatalogProduct[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "p01-5-4-a-05-a0008",
|
"id": "p01-5-4-a-05-a0008",
|
||||||
"category": "标准舵机",
|
"category": "异形舵机",
|
||||||
"name": "1.7g舵机(异形款/塑胶齿/三线)",
|
"name": "1.7g舵机(异形款/塑胶齿/三线)",
|
||||||
"code": "4.A.05.A0008",
|
"code": "4.A.05.A0008",
|
||||||
"image": "/catalog-products/p01-4-a-05-a0008.webp",
|
"image": "/catalog-products/p01-4-a-05-a0008.webp",
|
||||||
@@ -7170,8 +7170,8 @@ export const CATALOG_PRODUCTS: CatalogProduct[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const CATALOG_COUNTS: Record<string, number> = {
|
export const CATALOG_COUNTS: Record<string, number> = {
|
||||||
"标准舵机": 118,
|
"标准舵机": 117,
|
||||||
"异形舵机": 13,
|
"异形舵机": 14,
|
||||||
"全金属舵机": 66,
|
"全金属舵机": 66,
|
||||||
"大扭矩舵机": 26,
|
"大扭矩舵机": 26,
|
||||||
"积木舵机": 20,
|
"积木舵机": 20,
|
||||||
|
|||||||
@@ -863,7 +863,7 @@ export default function Home() {
|
|||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<p className="catalog-category-note">分类已按官方目录29页表头复核 · 七个主分类合计280款 · 静音舵机11款为标准舵机特色子集</p>
|
<p className="catalog-category-note">分类已按官方目录表头及业务规则复核 · 七个主分类合计280款 · 静音舵机11款为标准舵机特色子集</p>
|
||||||
|
|
||||||
<div className="catalog-toolbar">
|
<div className="catalog-toolbar">
|
||||||
<label className="catalog-search">
|
<label className="catalog-search">
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ CATEGORY_BY_PAGE = {
|
|||||||
**{page: "翻盖电机" for page in range(28, 30)},
|
**{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 = {
|
SPEC_LABELS = {
|
||||||
"标准舵机": [
|
"标准舵机": [
|
||||||
"产品尺寸", "最大砝码负载", "堵转扭矩", "空载速度", "可操作角度",
|
"产品尺寸", "最大砝码负载", "堵转扭矩", "空载速度", "可操作角度",
|
||||||
@@ -141,9 +146,9 @@ def main() -> None:
|
|||||||
|
|
||||||
with pdfplumber.open(PDF_PATH) as pdf:
|
with pdfplumber.open(PDF_PATH) as pdf:
|
||||||
for page_number, page in enumerate(pdf.pages, 1):
|
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 "")
|
page_text = clean(page.extract_text() or "")
|
||||||
expected_heading = f"{category}产品明细表"
|
expected_heading = f"{page_category}产品明细表"
|
||||||
if expected_heading not in page_text:
|
if expected_heading not in page_text:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
f"Category heading mismatch on page {page_number}: expected {expected_heading}"
|
f"Category heading mismatch on page {page_number}: expected {expected_heading}"
|
||||||
@@ -169,6 +174,7 @@ def main() -> None:
|
|||||||
code = clean_code(row[2])
|
code = clean_code(row[2])
|
||||||
if not code or not re.search(r"[A-Z].*\d", code):
|
if not code or not re.search(r"[A-Z].*\d", code):
|
||||||
continue
|
continue
|
||||||
|
category = CATEGORY_BY_CODE.get(code, page_category)
|
||||||
|
|
||||||
explicit_name = clean(row[1])
|
explicit_name = clean(row[1])
|
||||||
if explicit_name:
|
if explicit_name:
|
||||||
@@ -185,10 +191,10 @@ def main() -> None:
|
|||||||
crop_product_image(rendered, page.width, page.height, cell, IMAGE_DIR / image_name)
|
crop_product_image(rendered, page.width, page.height, cell, IMAGE_DIR / image_name)
|
||||||
inherited_image = f"/catalog-products/{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 = {
|
specs = {
|
||||||
label: value
|
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 != "/"
|
if value and value != "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user