1.5 KiB
1.5 KiB
Device Mapper Usage
This tool builds a cross-platform lookup index from workspace/brands/*.md.
1) Build index
python3 tools/device_mapper.py build
Output file: dist/device_index.json
2) Query from command line
python3 tools/device_mapper.py find --name 'iPhone14,5' --brand Apple
python3 tools/device_mapper.py find --name 'M2102J2SC' --brand Xiaomi
python3 tools/device_mapper.py find --name 'L55M5-AD' --brand Xiaomi
3) JSON structure
records: normalized device recordsdevice_name: standard marketing namebrand: normalized brandmanufacturer_brand: manufacturer-level brandmarket_brand: market sub-branddevice_type:phone | tablet | wear | tv | otheraliases: all searchable aliases
lookup: normalized alias -> candidaterecord.id[]brand_aliases: normalized brand aliases to filter by app-provided brandbrand_management: brand governance metadata
4) App-side integration
- Load
dist/device_index.jsoninto memory. - Normalize input
nameand optionalbrand. - Use
lookup[normalized_name]to fetch candidate records. - Normalize brand via
brand_management. - Filter records by normalized manufacturer or market brand when needed.
- Return first candidate or all candidates.
Normalization rule:
- lower-case
- keep only
[0-9a-z\u4e00-\u9fff] - remove spaces, hyphens, underscores and punctuation
5) Device type mapping
Supported categories:
phonetabletweartvother