Skip to content
This repository was archived by the owner on Feb 8, 2024. It is now read-only.

Commit 5b7fbbf

Browse files
author
Cipher
committed
Added export for JS
1 parent c1db2af commit 5b7fbbf

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

Janex.js

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,25 +230,6 @@ class IntentMatcher {
230230
throw new Error("No matching intent class found.");
231231
}
232232
}
233-
}
233+
};
234234

235-
// Example usage:
236-
const intentsFilePath = "./intents.json";
237-
const matcher = new IntentMatcher(intentsFilePath);
238-
239-
const rl = readline.createInterface({
240-
input: process.stdin,
241-
output: process.stdout,
242-
});
243-
244-
rl.question("You: ", (input) => {
245-
// Use the input here
246-
console.log("User input:", input);
247-
248-
// Close the readline interface
249-
rl.close();
250-
251-
const intentClass = matcher.patternCompare(input);
252-
const response = matcher.responseCompare(input, intentClass);
253-
console.log(response);
254-
});
235+
module.exports = IntentMatcher;

chat.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const readline = require("readline");
2+
const IntentMatcher = require("./Janex.js");
3+
4+
const intentsFilePath = "./intents.json";
5+
const matcher = new IntentMatcher(intentsFilePath);
6+
7+
const rl = readline.createInterface({
8+
input: process.stdin,
9+
output: process.stdout,
10+
});
11+
12+
rl.question("You: ", (input) => {
13+
// Use the input here
14+
console.log("User input:", input);
15+
16+
// Close the readline interface
17+
rl.close();
18+
19+
const intentClass = matcher.patternCompare(input);
20+
const response = matcher.responseCompare(input, intentClass);
21+
console.log(response);
22+
});

0 commit comments

Comments
 (0)