-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathindex.js
83 lines (75 loc) · 2.39 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
const readline = require('readline');
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log();
const samples = {
Search: {
EntitySearch: './Samples/entitySearch',
WebSearch: './Samples/webSearch',
VideoSearch: './Samples/videoSearch',
NewsSearch: './Samples/newsSearch',
ImageSearch: './Samples/imageSearch',
CustomSearch: './Samples/customSearch',
VisualSearch: './Samples/visualSearch',
AutoSuggest: './Samples/autoSuggest'
},
Vision: {
ComputerVision: './Samples/computerVision',
ContentModerator: './Samples/contentModerator',
CustomVisionImageClassify: './Samples/customVision/customVisionImgClassify',
CustomVisionObjectDetection: './Samples/customVision/customVisionObjDetect'
},
// Knowledge: {
// },
// Speech: {
// },
Language: {
SpellCheck: './Samples/spellCheck',
TextAnalytics: './Samples/textAnalytics'
}
}
const separator = "------------------------------------------------------------------------------------";
askCategory();
function askCategory() {
console.log("Hi! Which class of Cognitive Services would you like to sample? Pick one of the following: (CTRL+C to exit)");
console.log(separator);
console.log(Object.keys(samples).join(', '));
console.log(separator);
rl.question('', function (answer) {
if (samples.hasOwnProperty(answer)) {
console.log(`You picked: ${answer}`);
askSample(answer);
}
else {
console.log(`Sorry, \"${answer}\" doesn't seem to be a valid category.`);
askCategory();
}
});
}
function askSample(category) {
console.log(`Hi! Which ${category} API would you like to sample? Pick one of the following: (CTRL+C to exit)`);
console.log(separator);
console.log(Object.keys(samples[category]).join(', '));
console.log(separator);
rl.question('', function (answer) {
if (samples[category].hasOwnProperty(answer)) {
console.log(`Ok, running samples for ${answer}`);
const Sample = require(samples[category][answer]);
Sample.sample(rl);
if (!rl["keepOpen"]){
rl.close();
}
}
else {
console.log(`Sorry, \"${answer}\" doesn't seem to be a valid sample.`);
askSample(category);
}
});
}