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