-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-mapper.js
More file actions
76 lines (61 loc) · 1.79 KB
/
test-mapper.js
File metadata and controls
76 lines (61 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env node
/**
* Test harness for CommandMapper
* Usage: node test-mapper.js
*/
import CommandMapper from './src/mapper.js';
import { config, getProfile } from './src/config.js';
import Logger from './src/logger.js';
const logger = new Logger('debug');
console.log('\n=== MacroVox Command Mapper Test ===\n');
const mapper = new CommandMapper();
// Test cases: [phrase, profile, expectedKeyword]
const testCases = [
// Premiere exact matches
['undo', 'premiere', 'undo'],
['cut', 'premiere', 'cut'],
['render', 'premiere', 'render'],
['next frame', 'premiere', 'next frame'],
['reload', 'premiere', 'reload'],
// Premiere fuzzy matches
['undo please', 'premiere', 'undo'],
['cut that', 'premiere', 'cut'],
['next', 'premiere', 'next frame'],
['zoom in', 'premiere', 'zoom in'],
// Resolve
['undo', 'resolve', 'undo'],
['split', 'resolve', 'split'],
['play', 'resolve', 'play'],
// Gaming
['reload', 'gaming', 'reload'],
['jump', 'gaming', 'jump'],
['crouch', 'gaming', 'crouch'],
// Non-matches
['foobar', 'premiere', null],
['xyz', 'gaming', null],
];
let passed = 0;
let failed = 0;
for (const [phrase, profile, expected] of testCases) {
const result = mapper.mapPhrase(phrase, profile);
const matched = result ? result.keyword : null;
const success = matched === expected;
if (success) {
passed++;
console.log(`✓ "${phrase}" (${profile}) → "${matched}"`);
} else {
failed++;
console.log(
`✗ "${phrase}" (${profile}) → got "${matched}", expected "${expected}"`
);
if (result) {
console.log(
` (confidence: ${result.confidence.toFixed(2)}, method: ${result.method})`
);
}
}
}
console.log(`\n=== Results: ${passed} passed, ${failed} failed ===\n`);
if (failed > 0) {
process.exit(1);
}