mirror of
https://github.com/antvis/chart-visualization-skills.git
synced 2026-09-14 15:58:00 +08:00
b43ddb6543
* feat: skill use context service (#97) * feat: retrieve document as context with `zvec` (#87) * feat: 召回策略升级到 zvec * chore: 删除不必要的 createContext --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * fix: 修复 playground 图表渲染异常 (#88) Co-authored-by: 福晋 <liufu.lf@antgroup.com> * refactor: antv skill refactor (#90) * refactor: antv skill refactor * chore: remove reference data from the eval process * chore: update api path * chore: remove mistakes content * chore: includeInfo → includeConstraints --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * chore: skill content update (#93) * chore: skill content update * chore: update skill content --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * chore: skill rename to doc (#92) * chore: skill rename to doc * chore: code opt --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * refactor: use context for retrieval (#94) * refactor: use context for retrieval * chore: update dependence * chore: code opt * chore: update eval results * chore: cut down redundent code * chore: reduce external dependence * chore: update dependence version * fix: build * fix: utils * fix: test * chore: update node version --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * refactor: 简化代码 (#96) * refactor: 简化代码 * chore: remove command * chore: update timeout * feat: add cli and format output * feat: add maxTokens * docs: add publish action * chore: update tc * feat: use exist zvec * chore: 0.1.4 --------- Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * chore: merge master * chore: test should be first --------- Co-authored-by: Joel Alan <31396322+lxfu1@users.noreply.github.com> Co-authored-by: 福晋 <liufu.lf@antgroup.com> Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com> * chore: add postinstall * chore: improvement of retrieval quality (#99) * chore: improvement of retrieval quality * chore: remove content from dist * chore: remove default ftsFields * chore: update version --------- Co-authored-by: 福晋 <liufu.lf@antgroup.com> * chore: update retrieve host (#100) Co-authored-by: 福晋 <liufu.lf@antgroup.com> --------- Co-authored-by: hustcc <i@hust.cc> Co-authored-by: 福晋 <liufu.lf@antgroup.com> Co-authored-by: 逍为 <xiaowei.wzw@antgroup.com>
55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { expandQuery, synonyms } from '../src/synonyms';
|
|
|
|
describe('synonyms', () => {
|
|
describe('bidirectional map', () => {
|
|
it('should have Chinese → English entries', () => {
|
|
// Chinese → English
|
|
expect(synonyms['桑基图']).toContain('sankey');
|
|
expect(synonyms['树图']).toContain('treemap');
|
|
});
|
|
|
|
it('should have English → Chinese entries (auto-generated reverse)', () => {
|
|
// English → Chinese
|
|
expect(synonyms['sankey']).toContain('桑基图');
|
|
expect(synonyms['treemap']).toContain('矩形树图');
|
|
expect(synonyms['treemap']).toContain('树图');
|
|
});
|
|
|
|
it('should handle multi-valued synonyms', () => {
|
|
expect(synonyms['马赛克图']).toContain('mosaic');
|
|
expect(synonyms['马赛克图']).toContain('marimekko');
|
|
// Reverse: both mosaic and marimekko → 马赛克图
|
|
expect(synonyms['mosaic']).toContain('马赛克图');
|
|
expect(synonyms['marimekko']).toContain('马赛克图');
|
|
});
|
|
|
|
it('should not have duplicate entries', () => {
|
|
const treemapSynonyms = synonyms['treemap'];
|
|
expect(treemapSynonyms).toBeDefined();
|
|
const unique = new Set(treemapSynonyms);
|
|
expect(unique.size).toBe(treemapSynonyms.length);
|
|
});
|
|
});
|
|
|
|
describe('query expansion', () => {
|
|
it('should expand Chinese chart terms to English', () => {
|
|
expect(expandQuery('生成桑基图')).toBe('生成桑基图 sankey');
|
|
});
|
|
|
|
it('should expand English chart terms to Chinese', () => {
|
|
const result = expandQuery('create a treemap');
|
|
expect(result).toContain('矩形树图');
|
|
expect(result).toContain('树图');
|
|
});
|
|
|
|
it('should not duplicate existing synonyms', () => {
|
|
expect(expandQuery('桑基图 sankey')).toBe('桑基图 sankey');
|
|
});
|
|
|
|
it('should leave unknown queries unchanged', () => {
|
|
expect(expandQuery('未知图表')).toBe('未知图表');
|
|
});
|
|
});
|
|
});
|