@pinepaper.studio/mcp-server 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/taxonomy/classifier.d.ts +74 -0
- package/dist/taxonomy/classifier.d.ts.map +1 -0
- package/dist/taxonomy/classifier.js +448 -0
- package/dist/taxonomy/classifier.js.map +1 -0
- package/dist/taxonomy/error-recovery.d.ts +55 -0
- package/dist/taxonomy/error-recovery.d.ts.map +1 -0
- package/dist/taxonomy/error-recovery.js +205 -0
- package/dist/taxonomy/error-recovery.js.map +1 -0
- package/dist/taxonomy/index.d.ts +24 -0
- package/dist/taxonomy/index.d.ts.map +1 -0
- package/dist/taxonomy/index.js +25 -0
- package/dist/taxonomy/index.js.map +1 -0
- package/dist/taxonomy/matcher.d.ts +104 -0
- package/dist/taxonomy/matcher.d.ts.map +1 -0
- package/dist/taxonomy/matcher.js +473 -0
- package/dist/taxonomy/matcher.js.map +1 -0
- package/dist/taxonomy/registry.d.ts +56 -0
- package/dist/taxonomy/registry.d.ts.map +1 -0
- package/dist/taxonomy/registry.js +950 -0
- package/dist/taxonomy/registry.js.map +1 -0
- package/dist/taxonomy/types.d.ts +207 -0
- package/dist/taxonomy/types.d.ts.map +1 -0
- package/dist/taxonomy/types.js +29 -0
- package/dist/taxonomy/types.js.map +1 -0
- package/dist/tools/definitions.d.ts.map +1 -1
- package/dist/tools/definitions.js +409 -0
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/handlers.d.ts.map +1 -1
- package/dist/tools/handlers.js +10 -1
- package/dist/tools/handlers.js.map +1 -1
- package/dist/types/code-generator.d.ts +5 -1
- package/dist/types/code-generator.d.ts.map +1 -1
- package/dist/types/code-generator.js +168 -1
- package/dist/types/code-generator.js.map +1 -1
- package/dist/types/schemas.d.ts +219 -0
- package/dist/types/schemas.d.ts.map +1 -1
- package/dist/types/schemas.js +51 -0
- package/dist/types/schemas.js.map +1 -1
- package/manifest.json +6 -1
- package/package.json +1 -1
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Semantic Taxonomy Matcher
|
|
3
|
+
*
|
|
4
|
+
* Provides fast keyword-based matching with fallback to pattern matching.
|
|
5
|
+
* Uses a hybrid approach: keyword index for exact matches, pattern matching
|
|
6
|
+
* for fuzzy matches, and can be extended with embeddings for semantic search.
|
|
7
|
+
*/
|
|
8
|
+
import { ANIMATION_TAXONOMY, MODIFIER_NODES } from './registry.js';
|
|
9
|
+
/**
|
|
10
|
+
* Semantic Taxonomy Matcher
|
|
11
|
+
*
|
|
12
|
+
* Provides fast, multilingual matching of user input to taxonomy concepts.
|
|
13
|
+
*/
|
|
14
|
+
export class TaxonomyMatcher {
|
|
15
|
+
keywordIndex = new Map();
|
|
16
|
+
phraseIndex = new Map();
|
|
17
|
+
config;
|
|
18
|
+
initialized = false;
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
this.config = {
|
|
21
|
+
minConfidence: 0.6,
|
|
22
|
+
useSemanticSearch: false,
|
|
23
|
+
maxSuggestions: 3,
|
|
24
|
+
defaultLocale: 'en',
|
|
25
|
+
debug: false,
|
|
26
|
+
...config,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Initialize the matcher by building keyword indexes
|
|
31
|
+
*/
|
|
32
|
+
async initialize() {
|
|
33
|
+
if (this.initialized)
|
|
34
|
+
return;
|
|
35
|
+
this.buildKeywordIndex();
|
|
36
|
+
this.buildPhraseIndex();
|
|
37
|
+
this.initialized = true;
|
|
38
|
+
if (this.config.debug) {
|
|
39
|
+
console.log(`[TaxonomyMatcher] Initialized with ${this.keywordIndex.size} keywords`);
|
|
40
|
+
console.log(`[TaxonomyMatcher] Phrase index has ${this.phraseIndex.size} phrases`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Build the keyword index for fast lookups
|
|
45
|
+
*/
|
|
46
|
+
buildKeywordIndex() {
|
|
47
|
+
for (const node of ANIMATION_TAXONOMY) {
|
|
48
|
+
const locales = Object.keys(node.terms);
|
|
49
|
+
for (const locale of locales) {
|
|
50
|
+
const terms = node.terms[locale] || [];
|
|
51
|
+
for (const term of terms) {
|
|
52
|
+
// Index individual words
|
|
53
|
+
const words = term.toLowerCase().split(/\s+/);
|
|
54
|
+
for (const word of words) {
|
|
55
|
+
if (word.length < 2)
|
|
56
|
+
continue; // Skip very short words
|
|
57
|
+
const entry = {
|
|
58
|
+
term,
|
|
59
|
+
locale,
|
|
60
|
+
nodeId: node.id,
|
|
61
|
+
node,
|
|
62
|
+
priority: node.priority || 5,
|
|
63
|
+
};
|
|
64
|
+
if (!this.keywordIndex.has(word)) {
|
|
65
|
+
this.keywordIndex.set(word, []);
|
|
66
|
+
}
|
|
67
|
+
this.keywordIndex.get(word).push(entry);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Sort each keyword's entries by priority
|
|
73
|
+
for (const entries of this.keywordIndex.values()) {
|
|
74
|
+
entries.sort((a, b) => b.priority - a.priority);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build the phrase index for multi-word matches
|
|
79
|
+
*/
|
|
80
|
+
buildPhraseIndex() {
|
|
81
|
+
for (const node of ANIMATION_TAXONOMY) {
|
|
82
|
+
const locales = Object.keys(node.terms);
|
|
83
|
+
for (const locale of locales) {
|
|
84
|
+
const terms = node.terms[locale] || [];
|
|
85
|
+
for (const term of terms) {
|
|
86
|
+
// Only index multi-word phrases
|
|
87
|
+
if (term.includes(' ')) {
|
|
88
|
+
const normalized = term.toLowerCase();
|
|
89
|
+
const entry = {
|
|
90
|
+
term,
|
|
91
|
+
locale,
|
|
92
|
+
nodeId: node.id,
|
|
93
|
+
node,
|
|
94
|
+
priority: node.priority || 5,
|
|
95
|
+
};
|
|
96
|
+
if (!this.phraseIndex.has(normalized)) {
|
|
97
|
+
this.phraseIndex.set(normalized, []);
|
|
98
|
+
}
|
|
99
|
+
this.phraseIndex.get(normalized).push(entry);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Find the best matching taxonomy nodes for user input
|
|
107
|
+
*/
|
|
108
|
+
async findMatches(input, preferredLocale) {
|
|
109
|
+
if (!this.initialized) {
|
|
110
|
+
await this.initialize();
|
|
111
|
+
}
|
|
112
|
+
const normalizedInput = input.toLowerCase().trim();
|
|
113
|
+
const matches = new Map();
|
|
114
|
+
// 1. Try exact phrase matches first (highest confidence)
|
|
115
|
+
this.findPhraseMatches(normalizedInput, matches, preferredLocale);
|
|
116
|
+
// 2. Try keyword matches
|
|
117
|
+
this.findKeywordMatches(normalizedInput, matches, preferredLocale);
|
|
118
|
+
// 3. Try fuzzy/pattern matches
|
|
119
|
+
this.findPatternMatches(normalizedInput, matches, preferredLocale);
|
|
120
|
+
// Convert to array and sort by similarity
|
|
121
|
+
const results = Array.from(matches.values());
|
|
122
|
+
results.sort((a, b) => {
|
|
123
|
+
// First by similarity
|
|
124
|
+
if (b.similarity !== a.similarity) {
|
|
125
|
+
return b.similarity - a.similarity;
|
|
126
|
+
}
|
|
127
|
+
// Then by priority
|
|
128
|
+
return (b.node.priority || 5) - (a.node.priority || 5);
|
|
129
|
+
});
|
|
130
|
+
return results.slice(0, this.config.maxSuggestions * 2);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Find exact phrase matches
|
|
134
|
+
*/
|
|
135
|
+
findPhraseMatches(input, matches, preferredLocale) {
|
|
136
|
+
// Check for exact phrase matches
|
|
137
|
+
for (const [phrase, entries] of this.phraseIndex) {
|
|
138
|
+
if (input.includes(phrase)) {
|
|
139
|
+
for (const entry of entries) {
|
|
140
|
+
const existingMatch = matches.get(entry.nodeId);
|
|
141
|
+
const similarity = 0.95; // High confidence for phrase matches
|
|
142
|
+
// Boost if locale matches preferred
|
|
143
|
+
const localeBoost = preferredLocale === entry.locale ? 0.02 : 0;
|
|
144
|
+
if (!existingMatch || existingMatch.similarity < similarity + localeBoost) {
|
|
145
|
+
matches.set(entry.nodeId, {
|
|
146
|
+
nodeId: entry.nodeId,
|
|
147
|
+
similarity: similarity + localeBoost,
|
|
148
|
+
node: entry.node,
|
|
149
|
+
matchedTerm: entry.term,
|
|
150
|
+
matchedLocale: entry.locale,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Find keyword matches
|
|
159
|
+
*/
|
|
160
|
+
findKeywordMatches(input, matches, preferredLocale) {
|
|
161
|
+
const words = input.split(/\s+/);
|
|
162
|
+
for (const word of words) {
|
|
163
|
+
if (word.length < 2)
|
|
164
|
+
continue;
|
|
165
|
+
const entries = this.keywordIndex.get(word);
|
|
166
|
+
if (!entries)
|
|
167
|
+
continue;
|
|
168
|
+
for (const entry of entries) {
|
|
169
|
+
const existingMatch = matches.get(entry.nodeId);
|
|
170
|
+
// Calculate similarity based on word match
|
|
171
|
+
let similarity = 0.7; // Base confidence for keyword match
|
|
172
|
+
// Boost for exact word match in the term
|
|
173
|
+
const termWords = entry.term.toLowerCase().split(/\s+/);
|
|
174
|
+
if (termWords.includes(word)) {
|
|
175
|
+
similarity += 0.1;
|
|
176
|
+
}
|
|
177
|
+
// Boost for preferred locale
|
|
178
|
+
if (preferredLocale === entry.locale) {
|
|
179
|
+
similarity += 0.05;
|
|
180
|
+
}
|
|
181
|
+
// Boost for multiple word matches in same node
|
|
182
|
+
const matchingWords = words.filter((w) => entry.term.toLowerCase().includes(w) && w.length > 2);
|
|
183
|
+
similarity += Math.min(matchingWords.length * 0.05, 0.15);
|
|
184
|
+
if (!existingMatch || existingMatch.similarity < similarity) {
|
|
185
|
+
matches.set(entry.nodeId, {
|
|
186
|
+
nodeId: entry.nodeId,
|
|
187
|
+
similarity: Math.min(similarity, 0.95),
|
|
188
|
+
node: entry.node,
|
|
189
|
+
matchedTerm: entry.term,
|
|
190
|
+
matchedLocale: entry.locale,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Find pattern-based matches (fuzzy matching)
|
|
198
|
+
*/
|
|
199
|
+
findPatternMatches(input, matches, preferredLocale) {
|
|
200
|
+
// Skip if we already have high-confidence matches
|
|
201
|
+
const hasHighConfidence = Array.from(matches.values()).some((m) => m.similarity > 0.85);
|
|
202
|
+
if (hasHighConfidence)
|
|
203
|
+
return;
|
|
204
|
+
for (const node of ANIMATION_TAXONOMY) {
|
|
205
|
+
if (matches.has(node.id))
|
|
206
|
+
continue;
|
|
207
|
+
const locales = Object.keys(node.terms);
|
|
208
|
+
for (const locale of locales) {
|
|
209
|
+
const terms = node.terms[locale] || [];
|
|
210
|
+
for (const term of terms) {
|
|
211
|
+
const similarity = this.calculateStringSimilarity(input, term.toLowerCase());
|
|
212
|
+
if (similarity >= this.config.minConfidence) {
|
|
213
|
+
const localeBoost = preferredLocale === locale ? 0.03 : 0;
|
|
214
|
+
const existingMatch = matches.get(node.id);
|
|
215
|
+
if (!existingMatch || existingMatch.similarity < similarity + localeBoost) {
|
|
216
|
+
matches.set(node.id, {
|
|
217
|
+
nodeId: node.id,
|
|
218
|
+
similarity: similarity + localeBoost,
|
|
219
|
+
node,
|
|
220
|
+
matchedTerm: term,
|
|
221
|
+
matchedLocale: locale,
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Calculate string similarity using a combination of techniques
|
|
231
|
+
*/
|
|
232
|
+
calculateStringSimilarity(str1, str2) {
|
|
233
|
+
// Exact match
|
|
234
|
+
if (str1 === str2)
|
|
235
|
+
return 1.0;
|
|
236
|
+
// Contains check
|
|
237
|
+
if (str1.includes(str2) || str2.includes(str1)) {
|
|
238
|
+
const ratio = Math.min(str1.length, str2.length) / Math.max(str1.length, str2.length);
|
|
239
|
+
return 0.6 + ratio * 0.3;
|
|
240
|
+
}
|
|
241
|
+
// Word overlap
|
|
242
|
+
const words1 = new Set(str1.split(/\s+/));
|
|
243
|
+
const words2 = new Set(str2.split(/\s+/));
|
|
244
|
+
const intersection = new Set([...words1].filter((x) => words2.has(x)));
|
|
245
|
+
const union = new Set([...words1, ...words2]);
|
|
246
|
+
if (intersection.size > 0) {
|
|
247
|
+
return 0.5 + (intersection.size / union.size) * 0.4;
|
|
248
|
+
}
|
|
249
|
+
// Levenshtein-based similarity for short strings
|
|
250
|
+
if (str1.length < 20 && str2.length < 20) {
|
|
251
|
+
const distance = this.levenshteinDistance(str1, str2);
|
|
252
|
+
const maxLen = Math.max(str1.length, str2.length);
|
|
253
|
+
return Math.max(0, 1 - distance / maxLen) * 0.6;
|
|
254
|
+
}
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Calculate Levenshtein distance between two strings
|
|
259
|
+
*/
|
|
260
|
+
levenshteinDistance(str1, str2) {
|
|
261
|
+
const m = str1.length;
|
|
262
|
+
const n = str2.length;
|
|
263
|
+
if (m === 0)
|
|
264
|
+
return n;
|
|
265
|
+
if (n === 0)
|
|
266
|
+
return m;
|
|
267
|
+
const dp = Array(m + 1)
|
|
268
|
+
.fill(null)
|
|
269
|
+
.map(() => Array(n + 1).fill(0));
|
|
270
|
+
for (let i = 0; i <= m; i++)
|
|
271
|
+
dp[i][0] = i;
|
|
272
|
+
for (let j = 0; j <= n; j++)
|
|
273
|
+
dp[0][j] = j;
|
|
274
|
+
for (let i = 1; i <= m; i++) {
|
|
275
|
+
for (let j = 1; j <= n; j++) {
|
|
276
|
+
if (str1[i - 1] === str2[j - 1]) {
|
|
277
|
+
dp[i][j] = dp[i - 1][j - 1];
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
dp[i][j] = Math.min(dp[i - 1][j] + 1, // deletion
|
|
281
|
+
dp[i][j - 1] + 1, // insertion
|
|
282
|
+
dp[i - 1][j - 1] + 1);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return dp[m][n];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Detect modifiers in user input
|
|
290
|
+
*/
|
|
291
|
+
detectModifiers(input, locale) {
|
|
292
|
+
const normalizedInput = input.toLowerCase();
|
|
293
|
+
const results = [];
|
|
294
|
+
for (const modifier of MODIFIER_NODES) {
|
|
295
|
+
const locales = locale ? [locale, 'en'] : Object.keys(modifier.terms);
|
|
296
|
+
let matched = false;
|
|
297
|
+
let extractedValue;
|
|
298
|
+
for (const loc of locales) {
|
|
299
|
+
const patterns = modifier.terms[loc] || [];
|
|
300
|
+
for (const pattern of patterns) {
|
|
301
|
+
// Handle patterns with wildcards (*)
|
|
302
|
+
if (pattern.includes('*')) {
|
|
303
|
+
const regexPattern = pattern.replace(/\*/g, '(\\d+(?:\\.\\d+)?)');
|
|
304
|
+
const regex = new RegExp(regexPattern, 'i');
|
|
305
|
+
const match = normalizedInput.match(regex);
|
|
306
|
+
if (match) {
|
|
307
|
+
matched = true;
|
|
308
|
+
if (match[1]) {
|
|
309
|
+
extractedValue = parseFloat(match[1]);
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
// Simple substring match
|
|
316
|
+
if (normalizedInput.includes(pattern.toLowerCase())) {
|
|
317
|
+
matched = true;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (matched)
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
results.push({
|
|
326
|
+
modifier,
|
|
327
|
+
matched,
|
|
328
|
+
extractedValue,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
return results.filter((r) => r.matched);
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Extract parameter values from input using tool's extractors
|
|
335
|
+
*/
|
|
336
|
+
extractParameters(input, node, locale) {
|
|
337
|
+
const params = { ...node.tool.defaultParams };
|
|
338
|
+
const extractors = node.tool.parameterExtractors || [];
|
|
339
|
+
for (const extractor of extractors) {
|
|
340
|
+
const locales = locale ? [locale, 'en'] : Object.keys(extractor.patterns);
|
|
341
|
+
for (const loc of locales) {
|
|
342
|
+
const patterns = extractor.patterns[loc] || [];
|
|
343
|
+
for (const pattern of patterns) {
|
|
344
|
+
const match = input.match(pattern);
|
|
345
|
+
if (match && match[1]) {
|
|
346
|
+
params[extractor.param] = extractor.transform
|
|
347
|
+
? extractor.transform(match[1])
|
|
348
|
+
: match[1];
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (params[extractor.param] !== undefined)
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return params;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Detect the language of the input
|
|
360
|
+
* Simple heuristic based on character analysis
|
|
361
|
+
*/
|
|
362
|
+
detectLocale(input) {
|
|
363
|
+
// Check for CJK characters
|
|
364
|
+
if (/[\u4e00-\u9fff]/.test(input)) {
|
|
365
|
+
// Check for simplified vs traditional Chinese markers
|
|
366
|
+
if (/[\u7b80\u4f53]/.test(input))
|
|
367
|
+
return 'zh-CN';
|
|
368
|
+
if (/[\u7e41\u9ad4]/.test(input))
|
|
369
|
+
return 'zh-TW';
|
|
370
|
+
return 'zh-CN'; // Default to simplified
|
|
371
|
+
}
|
|
372
|
+
if (/[\u3040-\u309f\u30a0-\u30ff]/.test(input))
|
|
373
|
+
return 'ja';
|
|
374
|
+
if (/[\uac00-\ud7af]/.test(input))
|
|
375
|
+
return 'ko';
|
|
376
|
+
if (/[\u0e00-\u0e7f]/.test(input))
|
|
377
|
+
return 'th';
|
|
378
|
+
// Check for Arabic/Hebrew/Persian
|
|
379
|
+
if (/[\u0600-\u06ff]/.test(input)) {
|
|
380
|
+
if (/[\u0698\u067e\u0686\u06af]/.test(input))
|
|
381
|
+
return 'fa';
|
|
382
|
+
return 'ar';
|
|
383
|
+
}
|
|
384
|
+
if (/[\u0590-\u05ff]/.test(input))
|
|
385
|
+
return 'he';
|
|
386
|
+
// Check for Cyrillic
|
|
387
|
+
if (/[\u0400-\u04ff]/.test(input)) {
|
|
388
|
+
if (/[\u0456\u0457\u0491]/.test(input))
|
|
389
|
+
return 'uk';
|
|
390
|
+
return 'ru';
|
|
391
|
+
}
|
|
392
|
+
// Check for Devanagari and other Indic scripts
|
|
393
|
+
if (/[\u0900-\u097f]/.test(input))
|
|
394
|
+
return 'hi';
|
|
395
|
+
if (/[\u0980-\u09ff]/.test(input))
|
|
396
|
+
return 'bn';
|
|
397
|
+
if (/[\u0b80-\u0bff]/.test(input))
|
|
398
|
+
return 'ta';
|
|
399
|
+
if (/[\u0c00-\u0c7f]/.test(input))
|
|
400
|
+
return 'te';
|
|
401
|
+
// Check for specific European language patterns
|
|
402
|
+
const lowerInput = input.toLowerCase();
|
|
403
|
+
// Spanish markers
|
|
404
|
+
if (/[áéíóúñ¿¡]/.test(input) || /\b(el|la|los|las|que|de|en|un|una)\b/.test(lowerInput)) {
|
|
405
|
+
return 'es';
|
|
406
|
+
}
|
|
407
|
+
// French markers
|
|
408
|
+
if (/[àâäéèêëîïôùûüÿç]/.test(input) || /\b(le|la|les|de|du|des|que|est|un|une)\b/.test(lowerInput)) {
|
|
409
|
+
return 'fr';
|
|
410
|
+
}
|
|
411
|
+
// German markers
|
|
412
|
+
if (/[äöüß]/.test(input) || /\b(der|die|das|und|ist|ein|eine|auf|mit)\b/.test(lowerInput)) {
|
|
413
|
+
return 'de';
|
|
414
|
+
}
|
|
415
|
+
// Italian markers
|
|
416
|
+
if (/\b(il|lo|la|i|gli|le|di|che|non|per)\b/.test(lowerInput)) {
|
|
417
|
+
return 'it';
|
|
418
|
+
}
|
|
419
|
+
// Portuguese markers
|
|
420
|
+
if (/[ãõç]/.test(input) || /\b(o|a|os|as|de|que|do|da|em|um|uma)\b/.test(lowerInput)) {
|
|
421
|
+
return 'pt';
|
|
422
|
+
}
|
|
423
|
+
// Dutch markers
|
|
424
|
+
if (/\b(de|het|een|van|en|in|is|op|te|dat)\b/.test(lowerInput)) {
|
|
425
|
+
return 'nl';
|
|
426
|
+
}
|
|
427
|
+
// Default to English
|
|
428
|
+
return 'en';
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Get the best single match
|
|
432
|
+
*/
|
|
433
|
+
async findBestMatch(input, locale) {
|
|
434
|
+
const matches = await this.findMatches(input, locale);
|
|
435
|
+
return matches.length > 0 ? matches[0] : null;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Check if matcher is initialized
|
|
439
|
+
*/
|
|
440
|
+
isInitialized() {
|
|
441
|
+
return this.initialized;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get configuration
|
|
445
|
+
*/
|
|
446
|
+
getConfig() {
|
|
447
|
+
return { ...this.config };
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Update configuration
|
|
451
|
+
*/
|
|
452
|
+
setConfig(config) {
|
|
453
|
+
this.config = { ...this.config, ...config };
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
// Singleton instance
|
|
457
|
+
let matcherInstance = null;
|
|
458
|
+
/**
|
|
459
|
+
* Get or create the singleton TaxonomyMatcher instance
|
|
460
|
+
*/
|
|
461
|
+
export function getTaxonomyMatcher(config) {
|
|
462
|
+
if (!matcherInstance) {
|
|
463
|
+
matcherInstance = new TaxonomyMatcher(config);
|
|
464
|
+
}
|
|
465
|
+
return matcherInstance;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Reset the singleton instance (for testing)
|
|
469
|
+
*/
|
|
470
|
+
export function resetTaxonomyMatcher() {
|
|
471
|
+
matcherInstance = null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eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,eAAe,GAAG,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multilingual Semantic Taxonomy Registry
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive registry of concepts mapped to MCP tools.
|
|
5
|
+
* Each concept has terms in 41+ languages for robust intent detection.
|
|
6
|
+
*
|
|
7
|
+
* Schema.org References:
|
|
8
|
+
* - Actions: https://schema.org/Action
|
|
9
|
+
* - Creative Work: https://schema.org/CreativeWork
|
|
10
|
+
* - Visual Artwork: https://schema.org/VisualArtwork
|
|
11
|
+
* - Drawing: https://schema.org/Drawing
|
|
12
|
+
* - Thing: https://schema.org/Thing
|
|
13
|
+
*
|
|
14
|
+
* Wikidata References (for concepts not in schema.org):
|
|
15
|
+
* - Animation: https://www.wikidata.org/wiki/Q11425
|
|
16
|
+
* - Rotation: https://www.wikidata.org/wiki/Q7397
|
|
17
|
+
* - Orbit: https://www.wikidata.org/wiki/Q54363
|
|
18
|
+
*/
|
|
19
|
+
import type { TaxonomyNode, ModifierNode } from './types.js';
|
|
20
|
+
/**
|
|
21
|
+
* Motion-related taxonomy nodes
|
|
22
|
+
*/
|
|
23
|
+
export declare const MOTION_TAXONOMY: TaxonomyNode[];
|
|
24
|
+
/**
|
|
25
|
+
* Transformation-related taxonomy nodes
|
|
26
|
+
*/
|
|
27
|
+
export declare const TRANSFORMATION_TAXONOMY: TaxonomyNode[];
|
|
28
|
+
/**
|
|
29
|
+
* Item creation taxonomy nodes
|
|
30
|
+
*/
|
|
31
|
+
export declare const ITEM_TAXONOMY: TaxonomyNode[];
|
|
32
|
+
/**
|
|
33
|
+
* Background and generator taxonomy nodes
|
|
34
|
+
*/
|
|
35
|
+
export declare const BACKGROUND_TAXONOMY: TaxonomyNode[];
|
|
36
|
+
/**
|
|
37
|
+
* Timing and behavior modifiers
|
|
38
|
+
*/
|
|
39
|
+
export declare const MODIFIER_NODES: ModifierNode[];
|
|
40
|
+
/**
|
|
41
|
+
* Complete taxonomy - all nodes combined
|
|
42
|
+
*/
|
|
43
|
+
export declare const ANIMATION_TAXONOMY: TaxonomyNode[];
|
|
44
|
+
/**
|
|
45
|
+
* Get a taxonomy node by ID
|
|
46
|
+
*/
|
|
47
|
+
export declare function getTaxonomyNode(id: string): TaxonomyNode | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Get all nodes in a category
|
|
50
|
+
*/
|
|
51
|
+
export declare function getNodesByCategory(category: TaxonomyNode['category']): TaxonomyNode[];
|
|
52
|
+
/**
|
|
53
|
+
* Get modifier by ID
|
|
54
|
+
*/
|
|
55
|
+
export declare function getModifier(id: string): ModifierNode | undefined;
|
|
56
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/taxonomy/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAsB,MAAM,YAAY,CAAC;AA+GjF;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,YAAY,EAkRzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,YAAY,EA6FjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,YAAY,EA2LvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAAY,EAgI7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,YAAY,EAkIxC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAAY,EAK5C,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,YAAY,EAAE,CAErF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEhE"}
|