@astermind/cybernetic-chatbot-client 2.2.18 → 2.2.21

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.
@@ -3537,22 +3537,35 @@ LJ5AZXvOhHaXdHzMuYKX5BpK4w7TqbPvJ6QPvKmLKvHh1VKcUJ6mJQgJJw==
3537
3537
  }
3538
3538
  return '';
3539
3539
  }
3540
+ /**
3541
+ * Strip common articles and filler words for better matching
3542
+ */
3543
+ stripArticles(text) {
3544
+ return text
3545
+ .replace(/^(the|a|an|my|our|your|this|that)\s+/gi, '')
3546
+ .replace(/\s+(page|section|screen|view)$/gi, '')
3547
+ .trim();
3548
+ }
3540
3549
  /**
3541
3550
  * Find site map match for target string
3542
3551
  */
3543
3552
  findSiteMapMatch(target) {
3544
3553
  const normalizedTarget = target.toLowerCase().replace(/[^a-z0-9\s]/g, '');
3545
- // Exact match
3546
- const exact = this.siteMapIndex.get(normalizedTarget);
3554
+ const strippedTarget = this.stripArticles(normalizedTarget);
3555
+ // Exact match (try both with and without articles)
3556
+ const exact = this.siteMapIndex.get(normalizedTarget) || this.siteMapIndex.get(strippedTarget);
3547
3557
  if (exact) {
3548
3558
  return { entry: exact, similarity: 1.0 };
3549
3559
  }
3550
- // Fuzzy match
3560
+ // Fuzzy match using stripped version for better accuracy
3551
3561
  let bestMatch = null;
3552
3562
  let bestScore = 0;
3553
3563
  for (const [key, entry] of this.siteMapIndex) {
3554
- const score = this.calculateSimilarity(normalizedTarget, key);
3555
- if (score > bestScore && score > 0.6) {
3564
+ // Compare both original and stripped versions, take the better score
3565
+ const score1 = this.calculateSimilarity(normalizedTarget, key);
3566
+ const score2 = this.calculateSimilarity(strippedTarget, key);
3567
+ const score = Math.max(score1, score2);
3568
+ if (score > bestScore && score > 0.5) {
3556
3569
  bestScore = score;
3557
3570
  bestMatch = entry;
3558
3571
  }