diff --git a/py/LunaTranslator/cishu/__linggesi.py b/py/LunaTranslator/cishu/__linggesi.py deleted file mode 100644 index a0485b42..00000000 --- a/py/LunaTranslator/cishu/__linggesi.py +++ /dev/null @@ -1,68 +0,0 @@ -from myutils.utils import autosql -import sqlite3 -import winsharedutils -import os -from cishu.cishubase import cishubase, DictTree - - -class linggesi(cishubase): - def init(self): - self.sql = None - try: - if ( - os.path.exists(os.path.join(self.config["path"], "ja-zh.db")) == False - or os.path.exists(os.path.join(self.config["path"], "ja-zh-gbk.db")) - == False - ): - return - self.sql = autosql( - sqlite3.connect( - os.path.join(self.config["path"], "ja-zh.db"), - check_same_thread=False, - ) - ) - self.sql2 = sqlite3.connect( - os.path.join(self.config["path"], "ja-zh-gbk.db"), - check_same_thread=False, - ) - except: - pass - - def search(self, word): - if not self.sql: - return - mp = {} - for sql in [self.sql, self.sql2]: - x = sql.execute( - "select word,content from entry where word like ?", - ("%{}%".format(word),), - ) - exp = x.fetchall() - - for w, xx in exp: - - d = winsharedutils.distance(w, word) - if d <= self.config["distance"]: - mp[w] = [xx, d] - - x = sorted(list(mp.keys()), key=lambda x: mp[x][1])[: self.config["max_num"]] - save = [w + "
" + mp[w][0] for w in x] - return "
".join(save) - - 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 word from entry" - ).fetchall(): - c.append(_[0]) - return c - - return DictTreeRoot(self) diff --git a/py/LunaTranslator/cishu/__xiaoxueguan.py b/py/LunaTranslator/cishu/__xiaoxueguan.py deleted file mode 100644 index 0db2385c..00000000 --- a/py/LunaTranslator/cishu/__xiaoxueguan.py +++ /dev/null @@ -1,67 +0,0 @@ -import sqlite3, os, re -import winsharedutils -from myutils.utils import argsort, autosql -from cishu.cishubase import cishubase, DictTree - - -class xiaoxueguan(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: str): - if not self.sql: - return - if word in "【】": - return - if not word.strip(): - return - x = self.sql.execute( - "select word,explanation from xiaoxueguanrizhong where word like ?", - ("%{}%".format(word),), - ) - exp = x.fetchall() - dis = 9999 - save = [] - dis = [] - for w, xx in exp: - w: str = w.strip() - if w.startswith("-"): - w = w[1:] - match1 = re.match("(.*?)【(.*?)】", w) - if match1: - pr, w = match1.groups() - d = min( - winsharedutils.distance(pr, word), winsharedutils.distance(w, word) - ) - else: - d = winsharedutils.distance(w, word) - if d <= self.config["distance"]: - dis.append(d) - - srt = argsort(dis)[: self.config["max_num"]] - save = ["" + exp[i][1].replace("\\n", "") for i in srt] - return "
".join(save) - - 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 word from xiaoxueguanrizhong" - ).fetchall(): - c.append(_[0]) - return c - - return DictTreeRoot(self) diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json index de912eb4..1509c0ae 100644 --- a/py/files/defaultconfig/config.json +++ b/py/files/defaultconfig/config.json @@ -1243,69 +1243,6 @@ } }, "cishu": { - "xiaoxueguan": { - "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 - } - }, - "use": false, - "name": "小学馆", - "type": "offline" - }, - "linggesi": { - "use": false, - "name": "灵格斯词典", - "args": { - "path": "", - "distance": 0, - "max_num": 10 - }, - "argstype": { - "path": { - "type": "file", - "name": "路径", - "dir": true - }, - "distance": { - "type": "intspin", - "name": "模糊匹配_编辑距离", - "min": 0, - "max": 100, - "step": 1 - }, - "max_num": { - "type": "intspin", - "name": "最大结果条数", - "min": 0, - "max": 9999, - "step": 1 - } - }, - "type": "offline" - }, "mojidict": { "use": false, "name": "Moji辞书",