shuangying0001-beep/field-aligner

中英文字段名对齐映射工具:把杂乱字段名(中/英/驼峰/下划线)映射到规范 key,支持别名与模糊匹配。适合对接第三方接口、ERP 字段整理、数据清洗。

¿Qué es field-aligner?

field-aligner is a Claude Code agent skill that 中英文字段名对齐映射工具:把杂乱字段名(中/英/驼峰/下划线)映射到规范 key,支持别名与模糊匹配。适合对接第三方接口、ERP 字段整理、数据清洗。.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add shuangying0001-beep/field-aligner

Installed? Explore more Investigación y análisis de datos skills: obra/superpowers, affaan-m/quarkus-verification, affaan-m/uspto-database · View all 6 →

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

field-aligner —— 字段名模糊匹配与对齐

把任意来源的字段名,映射到你定义的规范字段 key。中文/英文/驼峰/下划线混用都认得。 纯函数实现(Node ESM,零依赖)。词汇表可注入,默认带一份通用示例词表。

适用场景

  • 对接 ERP / 开放平台 / 内部中台:对方字段名和你库里的字段名不一致
  • 多数据源合并:不同系统同一含义字段叫法不同
  • 文档 / 表格结构化:把表头映射到标准字段

提供的函数

函数说明
normalize(name)归一化:小写 + 去 _-空格
buildVocabulary(input){key:[aliases]}[{key,aliases}] 规范为统一结构
matchField(name, vocabulary, opts?)单字段匹配,返回 {key, matched, score, via}
batchMatchFields(names, vocabulary, opts?)批量匹配
DEFAULT_VOCABULARY通用示例词表(电商/通用字段)

匹配策略:

  1. 精确:归一化后 key 或任一别名完全相等 → via:'exact'
  2. 模糊:子串包含(重叠越长分越高),分数 ≥ fuzzyThreshold(默认 0.6)→ via:'fuzzy'
  3. 都不中 → {key:null, matched:false, via:'none'}

用法

import { matchField, batchMatchFields, DEFAULT_VOCABULARY } from './scripts/field-aligner.mjs';

// 1) 用默认词表
const r = matchField('商品标题', DEFAULT_VOCABULARY);
// => { key: 'title', matched: true, score: 1, via: 'exact' }

// 2) 注入你自己的词表
const myVocab = {
  order_no:   ['订单号', '单号', 'orderNumber'],
  buyer_name: ['买家', '收货人', 'buyer'],
};
batchMatchFields(['订单号', '买家', '备注'], myVocab);
// => { 订单号:{key:'order_no',...}, 买家:{key:'buyer_name',...}, 备注:{key:null,...} }

自测

node scripts/field-aligner.mjs --selftest

Skills relacionados