feat:add new dicts

This commit is contained in:
zyronon
2025-09-17 00:43:34 +08:00
parent aad6f33001
commit cb88ed9468
7 changed files with 75594 additions and 61 deletions

79
js_node/转换文件.cjs Normal file
View File

@@ -0,0 +1,79 @@
let path = require("path");
let fs = require("fs");
const RESULT_DIR = path.join(__dirname, 'source');
const RESULT2_DIR = path.join(__dirname, 'result');
function getDefaultWord(val) {
return {
custom: false,
id: 0,
"word": "",
"phonetic0": "",
"phonetic1": "",
"trans": [],
"sentences": [],
"phrases": [],
"synos": [],
"relWords": {
"root": "",
"rels": []
},
"etymology": [],
...val
}
}
const safeString = (str) => (typeof str === 'string' ? str.trim() : '');
const safeSplit = (str, sep) =>
safeString(str) ? safeString(str).split(sep).filter(Boolean) : [];
(async () => {
const files = fs.readdirSync(RESULT_DIR).filter(f => f.endsWith('.json'));
for (const file of files) {
const filePath = path.join(RESULT_DIR, file);
const raw = JSON.parse(fs.readFileSync(filePath, 'utf-8'));
console.log(raw.length)
let list = raw.map((v, i) => {
const trans = v.trans.map(line => {
const regex = /(n|vt|vi|adj)\.\s*([^vna]+?)(?=\s*(n\.|vt\.|vi\.|adj\.|$))/g;
let result = [];
let match1;
while ((match1 = regex.exec(line)) !== null) {
result.push(match1[1] + ". " + match1[2].trim());
}
if (!result.length) {
return [line]
}
return result;
}).flat().map(line => {
const match = line.match(/^([^\s.]+\.?)\s*(.*)$/);
if (match) {
let pos = safeString(match[1]);
let cn = safeString(match[2]);
// 如果 pos 不是常规词性(不以字母开头),例如 "【名】"
if (!/^[a-zA-Z]+\.?$/.test(pos)) {
cn = safeString(line); // 整行放到 cn
pos = ''; // pos 置空
}
return {pos, cn};
}
return {pos: '', cn: safeString(line)};
});
return getDefaultWord({
word: v.name,
phonetic0: v.usphone || '',
phonetic1: v.ukphone || '',
trans,
})
})
fs.writeFileSync(path.join(RESULT2_DIR, file), JSON.stringify(list, null, 2), 'utf-8');
}
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -130,8 +130,8 @@ async function refreshCDN() {
async function main() {
const files = getAllFiles('./dist')
console.log(`📁 共找到 ${files.length} 个文件,开始上传...`)
await uploadFilesWithClean(files, './dist', ['dicts', 'sound', 'libs'])
// await uploadFilesWithClean(files, './dist', ['libs'])
// await uploadFilesWithClean(files, './dist', ['dicts', 'sound', 'libs'])
await uploadFilesWithClean(files, './dist', ['libs'])
await refreshCDN()
}

View File

@@ -649,6 +649,32 @@
"length": 6268,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "coder",
"name": "Coder Dict",
"description": "程序员常见单词词库",
"category": "代码练习",
"tags": [
"通用"
],
"url": "it-words.json",
"length": 1700,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "itVocabulary",
"name": "计算机专用英语",
"description": "大学计算机专业英语词汇",
"category": "代码练习",
"tags": [
"通用"
],
"url": "itVocabulary.json",
"length": 1665,
"language": "en",
"translateLanguage": "zh-CN"
}
],
[
@@ -1916,65 +1942,13 @@
"translateLanguage": "zh-CN"
},
{
"id": "nce1",
"id": "nce-new-1",
"name": "新概念英语-1",
"description": "新概念英语第一册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "NCE_1.json",
"length": 900,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce2",
"name": "新概念英语-2",
"description": "新概念英语第二册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "NCE_2.json",
"length": 858,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce3",
"name": "新概念英语-3",
"description": "新概念英语第三册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "NCE_3.json",
"length": 1052,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce4",
"name": "新概念英语-4",
"description": "新概念英语第四册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "NCE_4.json",
"length": 784,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce-new-1",
"name": "新概念英语(新版)-1",
"description": "新概念英语新版第一册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "nce-new-1.json",
"length": 908,
"language": "en",
@@ -1982,8 +1956,8 @@
},
{
"id": "nce-new-2",
"name": "新概念英语(新版)-2",
"description": "新概念英语新版第二册",
"name": "新概念英语-2",
"description": "新概念英语第二册",
"category": "青少年英语",
"tags": [
"新概念英语"
@@ -1995,8 +1969,8 @@
},
{
"id": "nce-new-3",
"name": "新概念英语(新版)-3",
"description": "新概念英语新版第三册",
"name": "新概念英语-3",
"description": "新概念英语第三册",
"category": "青少年英语",
"tags": [
"新概念英语"
@@ -2008,8 +1982,8 @@
},
{
"id": "nce-new-4",
"name": "新概念英语(新版)-4",
"description": "新概念英语新版第四册",
"name": "新概念英语-4",
"description": "新概念英语第四册",
"category": "青少年英语",
"tags": [
"新概念英语"

View File

@@ -102,5 +102,83 @@
"length": 3893,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "coder",
"name": "Coder Dict",
"description": "程序员常见单词词库",
"category": "代码练习",
"tags": [
"通用"
],
"url": "it-words.json",
"length": 1700,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "itVocabulary",
"name": "计算机专用英语",
"description": "大学计算机专业英语词汇",
"category": "代码练习",
"tags": [
"通用"
],
"url": "itVocabulary.json",
"length": 1665,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce-new-1",
"name": "新概念英语-1",
"description": "新概念英语第一册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "nce-new-1.json",
"length": 908,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce-new-2",
"name": "新概念英语-2",
"description": "新概念英语第二册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "nce-new-2.json",
"length": 862,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce-new-3",
"name": "新概念英语-3",
"description": "新概念英语第三册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "nce-new-3.json",
"length": 1062,
"language": "en",
"translateLanguage": "zh-CN"
},
{
"id": "nce-new-4",
"name": "新概念英语-4",
"description": "新概念英语第四册",
"category": "青少年英语",
"tags": [
"新概念英语"
],
"url": "nce-new-4.json",
"length": 793,
"language": "en",
"translateLanguage": "zh-CN"
}
]

View File

@@ -51,6 +51,7 @@ const groupedByCategoryAndTag = $computed(() => {
for (const [key, value] of Object.entries(groupByCategory)) {
data.push([key, groupByDictTags(value)])
}
[data[2], data[3]] = [data[3], data[2]];
return data
})