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