update
This commit is contained in:
parent
c2efd0dc14
commit
0ef7d7cd2c
14
index.js
14
index.js
@ -67,11 +67,21 @@ function appendFile(string) {
|
||||
})
|
||||
}
|
||||
|
||||
// 答案转sql
|
||||
// 数据转txt
|
||||
/*
|
||||
var a = [];
|
||||
console.log(a.map((s) => `${s.chinese}\|\|\|${s.english}`).join('\n'));
|
||||
*/
|
||||
|
||||
// txt转sql
|
||||
function convertAnswerTxtToSql() {
|
||||
let lines = fs.readFileSync('answer.txt', 'utf8').split(/[\n\r]/);
|
||||
lines = Array.from(new Set(lines)).filter(s => !!s).map(s => {
|
||||
return `INSERT INTO \`answer\` (text) VALUES ('${s.replace('。', '')}');`;
|
||||
s = s.split(`\|\|\|`);
|
||||
let chinese = s[0] || ''.replace(/[。!]/g, ''); // 去掉标点符号
|
||||
let english = (s[1] || '').replace(/'/g, '\'\''); // ' 转义
|
||||
english = english;
|
||||
return `INSERT INTO \`answer\` (\`chinese\`, \`english\`) VALUES ('${chinese}', '${english}');`;
|
||||
}).sort();
|
||||
fs.writeFileSync('answer.sql', lines.join('\n'));
|
||||
}
|
||||
|
2013
sql/answer.sql
2013
sql/answer.sql
File diff suppressed because it is too large
Load Diff
@ -9,18 +9,12 @@ USE `answerbook`;
|
||||
-- Table structure for answer
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `answer`;
|
||||
|
||||
CREATE TABLE `answer` (
|
||||
`wy_id` int(11) DEFAULT NULL COMMENT '网易id',
|
||||
`text` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '问题答案',
|
||||
UNIQUE KEY `wy_id` (`wy_id`,`text`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
|
||||
|
||||
CREATE TABLE `answer` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`text` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '问题答案',
|
||||
`chinese` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '中文',
|
||||
`english` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '英文',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `text` (`text`)
|
||||
UNIQUE KEY `text` (`chinese`,`english`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
|
||||
SET
|
||||
|
Loading…
Reference in New Issue
Block a user