-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_tag_similarity.js
More file actions
49 lines (38 loc) · 2.23 KB
/
test_tag_similarity.js
File metadata and controls
49 lines (38 loc) · 2.23 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
// Test script to verify tag similarity functionality
import { invoke } from '@tauri-apps/api/core';
async function testTagSimilarity() {
console.log('Testing tag similarity functionality...\n');
try {
// Create some initial tags
console.log('1. Creating initial tags...');
await invoke('create_tag', { name: 'javascript', color: '#f7df1e' });
await invoke('create_tag', { name: 'react', color: '#61dafb' });
await invoke('create_tag', { name: 'programming', color: '#3776ab' });
console.log('Initial tags created.\n');
// Test similar tag creation (should reuse existing)
console.log('2. Testing similar tag creation...');
const tag1 = await invoke('create_tag', { name: 'JavaScript' }); // Different case
console.log(`Created tag "JavaScript": ${tag1.name} (ID: ${tag1.id})`);
const tag2 = await invoke('create_tag', { name: 'javascrpt' }); // Typo
console.log(`Created tag "javascrpt": ${tag2.name} (ID: ${tag2.id})`);
const tag3 = await invoke('create_tag', { name: 'React' }); // Different case
console.log(`Created tag "React": ${tag3.name} (ID: ${tag3.id})\n`);
// Test finding similar tags
console.log('3. Testing find similar tags...');
const similar1 = await invoke('find_similar_tags', { query: 'js', threshold: 0.3 });
console.log('Similar tags for "js":', similar1.map(([tag, score]) => `${tag.name} (${Math.round(score * 100)}%)`));
const similar2 = await invoke('find_similar_tags', { query: 'react.js', threshold: 0.5 });
console.log('Similar tags for "react.js":', similar2.map(([tag, score]) => `${tag.name} (${Math.round(score * 100)}%)`));
const similar3 = await invoke('find_similar_tags', { query: 'programing', threshold: 0.7 });
console.log('Similar tags for "programing":', similar3.map(([tag, score]) => `${tag.name} (${Math.round(score * 100)}%)`));
// Get all tags to verify
console.log('\n4. All tags in the system:');
const allTags = await invoke('get_all_tags');
allTags.forEach(tag => console.log(`- ${tag.name} (ID: ${tag.id})`));
console.log('\nTag similarity test completed successfully!');
} catch (error) {
console.error('Test failed:', error);
}
}
// Run the test
testTagSimilarity();