45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const utils = require('../../utils');
|
|
|
|
// const input = fs.readFileSync(path.join(__dirname, './data/最常用的500个汉字.txt'), 'utf8')
|
|
|
|
// let list = input.split(/[\r\n]/).join('')
|
|
|
|
// console.log("converting...")
|
|
// for (let w of list) {
|
|
// // console.log(w)
|
|
// let struct = utils.structure()
|
|
// struct.word = w
|
|
// struct.type = 1
|
|
// struct.from.push("2")
|
|
// utils.addData(struct, false)
|
|
// }
|
|
// utils.saveData()
|
|
// console.log("done")
|
|
|
|
const input = fs.readFileSync(path.join(__dirname, './data/带笔画.txt'), 'utf8')
|
|
|
|
let list = input.replace(/[\r\n、]/g, "|").replace(/\|+/g, "|").split('|')
|
|
|
|
console.log("converting...")
|
|
let stroke = 0
|
|
let temp = {}
|
|
for (let w of list) {
|
|
if (w.length > 1) {
|
|
stroke++
|
|
} else {
|
|
temp[stroke] = (temp[stroke] || "") + w
|
|
|
|
let struct = utils.structure()
|
|
struct.word = w
|
|
struct.stroke = stroke
|
|
struct.type = 1
|
|
struct.from.push("2")
|
|
utils.addData(struct, false)
|
|
}
|
|
}
|
|
console.log(temp)
|
|
utils.saveData()
|
|
console.log("done")
|