1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
Chinese-characters/original/1/convert.js
2022-12-08 22:10:09 +08:00

27 lines
793 B
JavaScript

const fs = require('fs');
const path = require('path');
const utils = require('../../utils');
const input = fs.readFileSync(path.join(__dirname, './data.txt'), 'utf8')
let list = input.split(/[\r\n]/).filter(i => i.length > 1).join(' ').split(' ')
console.log("converting...")
for (let item of list) {
let w = item.match(/(.)\((.*)\)/)
if (w.length < 2) {
console.log("正则匹配失败", item)
continue
}
let struct = utils.structure()
struct.word = w[1]
struct.type = 1
struct.pinyin.push(w[2])
struct.from.push("1")
utils.addData(struct, false)
// console.log(item, w, struct)
}
utils.saveData()
console.log("done")
// fs.writeFileSync(path.join(__dirname, './output.txt'), JSON.stringify(list), 'utf8')