1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
Chinese-characters/original/4/convert.js
2022-12-08 23:01:31 +08:00

38 lines
1.0 KiB
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.trim().replace(/[\r\n]+/g, "\n").split("\n")
console.log(list)
let radical = ""
let isWord = false
let pinyin = []
for (let i = 0; i < list.length; i++) {
const item = list[i].trim()
let match = item.match(/(.) 字母开头的汉字/)
if (match) {
// 新的字母开头开始了
radical = match[1]
} else {
// 这是汉字或者拼音
if (!isWord) {
// 拼音
pinyin = item.split(' ').sort()
} else {
// 汉字
let struct = utils.structure()
struct.word = item
struct.pinyin = pinyin
struct.from.push("4")
utils.addData(struct, false)
// console.log(item, pinyin)
}
isWord = !isWord
}
}
utils.saveData()
console.log("done")