Update zetahack.js
Browse files- zetahack.js +22 -20
zetahack.js
CHANGED
|
@@ -64,34 +64,36 @@ function zetahack(input) {
|
|
| 64 |
];
|
| 65 |
|
| 66 |
function detectIntent(text) {
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 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 |
-
|
| 93 |
-
|
| 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;
|