-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (28 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const trainModel = require('./train');
const startServer = require('./server');
const loadModel = require('./load');
const processInput = require('./process');
const command = process.argv[2];
(async () => {
if (command === 'train') {
await trainModel();
} else if (command === 'api') {
const manager = loadModel();
await startServer(manager);
} else if (command === 'simple_qna') {
const input = process.argv[3];
const language = process.argv[4] || 'en';
if (!input) {
console.error('Please provide an input text for simple_qna');
process.exit(1);
}
const manager = loadModel();
const answer = await processInput(manager, language, input);
console.log(answer);
} else {
console.log('Usage:');
console.log(' node index.js train - to train and save the model');
console.log(' node index.js api - to start the API server');
console.log(' node index.js simple_qna <text> [language] - to process a single input');
}
})();