Skip to content

Commit 90cd59f

Browse files
committed
add code preparation for single-feature and multi-feature
1 parent 9be4897 commit 90cd59f

File tree

3 files changed

+80
-38
lines changed

3 files changed

+80
-38
lines changed

src/main.js

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import csv from 'csv-parser'
88
import Table from 'cli-table3'
99
import readlineSync from 'readline-sync'
1010

11-
11+
import singleFeatureProcess from './single-feature.js'
12+
import multiFeatureProcess from './multi-feature.js'
1213

1314

1415
/**
@@ -161,54 +162,42 @@ async function previewData(filePath) {
161162
print('\n-----------------------------------------------------\n')
162163
print('Preview data: ', filePath)
163164

164-
await Promise.all([readFileAsync(path.join(DATA_DIR, filePath))])
165-
165+
await readFileAsync(path.join(DATA_DIR, filePath))
166166

167167
if (readlineSync.keyInYNStrict(chalk.green('\nContinue next process'))) {
168-
dataIdentification()
168+
await dataIdentification()
169169
}
170170
}
171171

172172

173173

174174

175-
function dataIdentification() {
175+
async function dataIdentification() {
176176
print('\n-----------------------------------------------------\n')
177-
print('Data identification!')
178-
179-
const feature = readlineSync.question('Choose feature: ')
180-
const label = readlineSync.question('Choose label: ')
181-
182-
if (readlineSync.keyInYNStrict(chalk.green('\nContinue process data'))) {
183-
processing()
184-
}
185-
}
177+
print('Data identification')
186178

187179

180+
const answers = await inquirer.prompt([
181+
{
182+
type: 'list',
183+
name: 'type',
184+
message: 'Choose model type',
185+
choices: [
186+
'1. Single feature',
187+
'2. Multi feature'
188+
]
189+
}
190+
])
188191

189-
190-
function processing() {
191-
print('\n-----------------------------------------------------\n')
192-
print('Model processing!')
193-
for (let i = 1; i <= 20; i++) {
194-
print('iteration: ', i)
195-
}
196-
197-
if (readlineSync.keyInYNStrict(chalk.green('\nShow visualization'))) {
198-
visualization()
192+
switch (answers.type) {
193+
case '1. Single feature':
194+
singleFeatureProcess()
195+
break;
196+
case '2. Multi feature':
197+
multiFeatureProcess()
198+
break;
199+
default:
200+
print('Invalid input!')
201+
break;
199202
}
200203
}
201-
202-
203-
204-
205-
206-
function visualization() {
207-
print('\n-----------------------------------------------------\n')
208-
print('Visualization here!')
209-
print('Graph, chart, or whatever...')
210-
211-
212-
// 7
213-
print('Show the prove of linear equation is actually match with user data')
214-
}

src/multi-feature.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import chalk from 'chalk'
2+
import readlineSync from 'readline-sync'
3+
4+
5+
const print = console.log;
6+
7+
8+
export default function multiFeatureProcess() {
9+
print('Multi feature process')
10+
11+
if (readlineSync.keyInYNStrict(chalk.green('\nShow visualization'))) {
12+
visualization()
13+
}
14+
}
15+
16+
17+
18+
function visualization() {
19+
print('\n-----------------------------------------------------\n')
20+
print('Visualization here!')
21+
print('Graph, chart, or whatever...')
22+
23+
24+
// 7
25+
print('Show the prove of linear equation is actually match with user data')
26+
}

src/single-feature.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import chalk from 'chalk'
2+
import readlineSync from 'readline-sync'
3+
4+
5+
6+
const print = console.log;
7+
8+
9+
export default function singleFeatureProcess() {
10+
print('Single feature process')
11+
12+
if (readlineSync.keyInYNStrict(chalk.green('\nShow visualization'))) {
13+
visualization()
14+
}
15+
}
16+
17+
18+
19+
function visualization() {
20+
print('\n-----------------------------------------------------\n')
21+
print('Visualization here!')
22+
print('Graph, chart, or whatever...')
23+
24+
25+
// 7
26+
print('Show the prove of linear equation is actually match with user data')
27+
}

0 commit comments

Comments
 (0)