NeuralNexusLab-Nh commited on
Commit
49f8c73
·
verified ·
1 Parent(s): 05e7b98

Update zetahack.js

Browse files
Files changed (1) hide show
  1. zetahack.js +22 -20
zetahack.js CHANGED
@@ -64,34 +64,36 @@ function zetahack(input) {
64
  ];
65
 
66
  function detectIntent(text) {
67
- const lowerText = text.toLowerCase();
68
- const words = lowerText.split(/\s+/);
69
-
70
- for (const [category, keywords] of Object.entries(keyDB)) {
71
- if (keywords.some(keyword => lowerText.includes(keyword))) {
72
- if (category === 'math' && hasMathOperation(lowerText)) {
73
- return 'math_calculation';
74
- }
75
- return category;
76
- }
77
- }
78
-
79
- if (isEmotional(lowerText)) return 'emotional_support';
80
- if (isGreeting(lowerText)) return 'greeting';
81
- if (isIdentityQuery(lowerText)) return 'identity';
82
-
83
- return 'general';
84
  }
85
 
 
86
  function hasMathOperation(text) {
87
  const mathWords = [...mathExpressions.add, ...mathExpressions.subtract, ...mathExpressions.multiply, ...mathExpressions.divide];
88
  return mathWords.some(word => text.includes(word)) || /\d+[\+\-\*\/]\d+/.test(text);
89
  }
90
 
91
  function isEmotional(text) {
92
- const emotionalWords = keyDB.emotion;
93
- return emotionalWords.some(word => text.includes(word));
94
- }
 
95
 
96
  function isGreeting(text) {
97
  const greetings = keyDB.greeting;
 
64
  ];
65
 
66
  function detectIntent(text) {
67
+ const lowerText = text.toLowerCase();
68
+ if (isEmotional(lowerText)) return 'emotional_support';
69
+ for (const [category, keywords] of Object.entries(keyDB)) {
70
+ if (keywords.some(keyword => lowerText.includes(keyword))) {
71
+ if (category === 'math' && hasMathOperation(lowerText)) {
72
+ return 'math_calculation';
73
+ }
74
+ if (category === 'emotion') {
75
+ return 'emotional_support';
76
+ }
77
+ return category;
78
+ }
79
+ }
80
+ if (isGreeting(lowerText)) return 'greeting';
81
+ if (isIdentityQuery(lowerText)) return 'identity';
82
+
83
+ return 'general';
84
  }
85
 
86
+
87
  function hasMathOperation(text) {
88
  const mathWords = [...mathExpressions.add, ...mathExpressions.subtract, ...mathExpressions.multiply, ...mathExpressions.divide];
89
  return mathWords.some(word => text.includes(word)) || /\d+[\+\-\*\/]\d+/.test(text);
90
  }
91
 
92
  function isEmotional(text) {
93
+ const emotionalWords = ['sad', 'happy', 'angry', 'excited', 'depressed', 'anxious', 'worried', 'stressed', 'tired', 'exhausted', 'feel', 'feeling', 'emotion'];
94
+ return emotionalWords.some(word => text.includes(word));
95
+ }
96
+
97
 
98
  function isGreeting(text) {
99
  const greetings = keyDB.greeting;