add 3
This commit is contained in:
82077
data-friendly.json
82077
data-friendly.json
File diff suppressed because it is too large
Load Diff
38
original/3/convert.js
Normal file
38
original/3/convert.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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.type = 2
|
||||
struct.from.push("3")
|
||||
utils.addData(struct, false)
|
||||
// console.log(item, pinyin)
|
||||
}
|
||||
isWord = !isWord
|
||||
}
|
||||
}
|
||||
|
||||
utils.saveData()
|
||||
console.log("done")
|
26770
original/3/data.txt
Normal file
26770
original/3/data.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,3 @@
|
||||
1 https://zhuanlan.zhihu.com/p/429504173
|
||||
2 https://baike.baidu.com/item/%E5%B8%B8%E7%94%A8%E5%AD%97/10071115?fr=aladdin
|
||||
3 https://m.gdzz114.com/shengpizi.html
|
15
utils.js
15
utils.js
@@ -26,7 +26,7 @@ function structure() {
|
||||
|
||||
function saveData() {
|
||||
const ObjSort = function (arys) {
|
||||
var newkey = Object.keys(arys).sort((a,b)=>a.localeCompare(b));
|
||||
var newkey = Object.keys(arys).sort((a, b) => a.localeCompare(b));
|
||||
var newObj = {}; //创建一个新的对象,用于存放排好序的键值对
|
||||
for (var i = 0; i < newkey.length; i++) {
|
||||
newObj[newkey[i]] = arys[newkey[i]];
|
||||
@@ -65,11 +65,22 @@ function addData(wordStruct, saveData = true) {
|
||||
// 合并类型
|
||||
if (wordStruct.type > 0 && wordStruct.type != struct.type) {
|
||||
if (struct.type != 0) {
|
||||
console.log(`${wordStruct.word} 字的类型(type)出现歧义 [${struct.type}, ${wordStruct.type}],当前保存 ${wordStruct.type}`)
|
||||
// 同时在生僻字和常见字出现 记为常见字
|
||||
console.log(`${wordStruct.word} 字的类型(type)出现歧义 [${struct.type}, ${wordStruct.type}],当前保存 1`)
|
||||
struct.type = 1
|
||||
}
|
||||
struct.type = wordStruct.type
|
||||
}
|
||||
|
||||
// 合并来源
|
||||
for (let fr of wordStruct.from) {
|
||||
if (!struct.from.includes(fr)) {
|
||||
struct.from.push(fr)
|
||||
isNeedUpdate = true
|
||||
}
|
||||
}
|
||||
struct.from.sort()
|
||||
|
||||
if (isNeedUpdate) {
|
||||
data[word] = struct
|
||||
saveData && saveData()
|
||||
|
Reference in New Issue
Block a user