From 5e19acfe488531cf72e5ce1cdf8fe68670ecc5d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com>
Date: Sat, 14 Dec 2024 19:54:50 +0800
Subject: [PATCH] .
---
py/LunaTranslator/cishu/__edict.py | 59 ---------------------------
py/LunaTranslator/cishu/__edict2.py | 58 --------------------------
py/files/defaultconfig/config.json | 63 -----------------------------
3 files changed, 180 deletions(-)
delete mode 100644 py/LunaTranslator/cishu/__edict.py
delete mode 100644 py/LunaTranslator/cishu/__edict2.py
diff --git a/py/LunaTranslator/cishu/__edict.py b/py/LunaTranslator/cishu/__edict.py
deleted file mode 100644
index 5c0ecfbf..00000000
--- a/py/LunaTranslator/cishu/__edict.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import sqlite3, os
-import winsharedutils, re
-from myutils.utils import argsort, autosql
-from cishu.cishubase import cishubase, DictTree
-
-
-class edict(cishubase):
- def init(self):
- self.sql = None
- try:
- path = self.config["path"]
- if os.path.exists(path):
- self.sql = autosql(sqlite3.connect(path, check_same_thread=False))
- except:
- pass
-
- def search(self, word):
- if not self.sql:
- return
- x = self.sql.execute(
- "select text, entry_id from surface where text like ?",
- ("%{}%".format(word),),
- )
- exp = x.fetchall()
- dis = 9999
- dis = []
- for w, xx in exp:
- d = winsharedutils.distance(w, word)
- if d <= self.config["distance"]:
- dis.append(d)
- save = []
- srt = argsort(dis)
- for ii in srt[: self.config["max_num"]]:
- if exp[ii][1] not in save:
- save.append(exp[ii][1])
- saveres = []
- for _id in save:
- x = self.sql.execute(
- "select word, content from entry where id =?", (_id,)
- ).fetchone()
- saveres.append(x[0] + "
" + re.sub("/EntL.*/", "", x[1][1:]))
-
- return "
".join(saveres)
-
- def tree(self):
- if not self.sql:
- return
-
- class DictTreeRoot(DictTree):
- def __init__(self, ref) -> None:
- self.ref = ref
-
- def childrens(self):
- c = []
- for _ in self.ref.sql.execute("select text from surface").fetchall():
- c.append(_[0])
- return c
-
- return DictTreeRoot(self)
diff --git a/py/LunaTranslator/cishu/__edict2.py b/py/LunaTranslator/cishu/__edict2.py
deleted file mode 100644
index dfbf14d0..00000000
--- a/py/LunaTranslator/cishu/__edict2.py
+++ /dev/null
@@ -1,58 +0,0 @@
-import winsharedutils, os
-import re
-from myutils.utils import argsort
-from traceback import print_exc
-from cishu.cishubase import cishubase, DictTree
-
-
-class edict2(cishubase):
- def init(self):
- self.save = None
- try:
- path = self.config["path"]
- if os.path.exists(path):
- with open(path, "r", encoding="euc-jp") as ff:
- _ = ff.read()
- _ = _.split("\n")[1:]
- self.save = {}
- for _l in _:
- try:
- _s = _l.index(" ")
- except:
- continue
- self.save[_l[:_s]] = _l[_s:]
- except:
- print_exc()
-
- def search(self, word):
- if not self.save:
- return
- dis = 9999
- dis = []
- savew = []
- for w in self.save:
- if word in w or w in word:
- d = winsharedutils.distance(w, word)
- if d <= self.config["distance"]:
- dis.append(d)
- savew.append(w)
- saveres = []
- srt = argsort(dis)
- for ii in srt[: self.config["max_num"]]:
- saveres.append(
- savew[ii] + "
" + re.sub("/EntL.*/", "", self.save[savew[ii]][1:])
- )
- return "
".join(saveres)
-
- def tree(self):
- if not self.save:
- return
-
- class DictTreeRoot(DictTree):
- def __init__(self, ref) -> None:
- self.ref = ref
-
- def childrens(self):
- return list(self.ref.save.keys())
-
- return DictTreeRoot(self)
diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json
index ddd9fedf..de912eb4 100644
--- a/py/files/defaultconfig/config.json
+++ b/py/files/defaultconfig/config.json
@@ -1275,69 +1275,6 @@
"name": "小学馆",
"type": "offline"
},
- "edict": {
- "use": false,
- "name": "EDICT",
- "args": {
- "path": "",
- "distance": 0,
- "max_num": 10
- },
- "argstype": {
- "path": {
- "type": "file",
- "name": "路径",
- "dir": false,
- "filter": "*.db"
- },
- "distance": {
- "type": "intspin",
- "name": "模糊匹配_编辑距离",
- "min": 0,
- "max": 100,
- "step": 1
- },
- "max_num": {
- "type": "intspin",
- "name": "最大结果条数",
- "min": 0,
- "max": 9999,
- "step": 1
- }
- },
- "type": "offline"
- },
- "edict2": {
- "use": false,
- "name": "EDICT2",
- "args": {
- "path": "",
- "distance": 0,
- "max_num": 10
- },
- "argstype": {
- "path": {
- "type": "file",
- "name": "路径",
- "dir": false
- },
- "distance": {
- "type": "intspin",
- "name": "模糊匹配_编辑距离",
- "min": 0,
- "max": 100,
- "step": 1
- },
- "max_num": {
- "type": "intspin",
- "name": "最大结果条数",
- "min": 0,
- "max": 9999,
- "step": 1
- }
- },
- "type": "offline"
- },
"linggesi": {
"use": false,
"name": "灵格斯词典",