Taxonomy Tree Merge
When to Use
- Merge multiple taxonomies into unified hierarchy
- Standardize e-commerce category systems
- Create 5-level category structure
Input Files
/root/data/amazon_product_categories.csv/root/data/fb_product_categories.csv/root/data/google_shopping_product_categories.csv
All contain category_path column with hierarchical paths like:
electronics > computers > Laptops
Facebook files may include extra columns (for example category_id) and may have a BOM-prefixed header. Read all three CSVs first, normalize column names, and confirm the category_path field before building the merge.
Use the provided CSVs directly when possible. Prefer a self-contained script/notebook over external pipelines unless an existing script is first inspected and verified to produce the exact required output files, columns, and hierarchy constraints.
Workflow
Workflow
- Inspect all three input CSVs before choosing an approach.
- Read headers and sample rows from each file.
- Confirm the
category_pathcolumn exists and note delimiter, casing, spacing, quoting, null-value, depth, or encoding issues.
- Work from the specified paths and scope.
- Read inputs only from
/root/data/and write outputs only to/root/output/. - Do not pivot to other CSVs, skill folders, or external frameworks unless the task explicitly authorizes them.
- Prefer simple, inspectable methods first.
- Start with deterministic normalization plus pandas and rule-based merging.
- Use heavier clustering, embeddings, or download-heavy libraries only if there is clear evidence they are needed and dependencies are available.
- Reuse existing code only after validation.
- If a helper script or pipeline exists, inspect its actual code or interface before using it.
- Verify it reads the available inputs, can produce the exact required output filenames and schema, and meets the hierarchy constraints.
- If no verified helper is suitable, write a small local end-to-end script that reads from
/root/dataand writes the required outputs.
- Make runtime decisions from observable evidence.
- Do not replace, interrupt, or optimize a running job unless logs, errors, stalled progress, timestamps, file growth, or measured bottlenecks show intervention is necessary.
- If you edit code or switch scripts, inspect the updated file or generated output before assuming the change took effect.
- Execute the merge end to end.
- Produce both
/root/output/unified_taxonomy_full.csvand/root/output/unified_taxonomy_hierarchy.csvbefore declaring success.
Rules
- Top level: 10-20 broad categories
- Each level: 3-20 subcategories per parent
- Use " | " separator, max 5 words per category
- Category name representative of 70%+ subcategories
- Standardize text, avoid overlap with parent
- Siblings: < 30% word overlap
- Balance cluster sizes (pyramid structure)
- Even distribution from all sources
Output Files
unified_taxonomy_full.csv
- source, category_path, depth (1-5)
- unified_level_1 through unified_level_5
unified_taxonomy_hierarchy.csv
- unified_level_1 through unified_level_5
- All paths from low to high granularity
Validation checklist before completion:
- Confirm
/root/output/unified_taxonomy_full.csvexists, is non-empty, and includessource,category_path,depth, andunified_level_1throughunified_level_5. - Confirm
/root/output/unified_taxonomy_hierarchy.csvexists, is non-empty, and includesunified_level_1throughunified_level_5. - Inspect a few rows from each file to confirm paths are populated consistently, use
|separators, and depths are within 1-5 where applicable. - Only declare completion after both required files are present and validated on disk; if the environment requires an exact completion signal such as
ACTION: TASK_COMPLETE, emit it verbatim after verification.
Tips
- pandas for CSV processing
- Hierarchical clustering or rule-based merging
- Text similarity for disambiguation