mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
remove
This commit is contained in:
parent
731ab0a08f
commit
b9dc1d12de
@ -1,42 +0,0 @@
|
||||
import os
|
||||
import requests
|
||||
from urllib.parse import quote
|
||||
import re, json
|
||||
from myutils.proxy import getproxy
|
||||
from cishu.cishubase import cishubase
|
||||
|
||||
|
||||
class yomichan(cishubase):
|
||||
def init(self):
|
||||
self.sql = None
|
||||
|
||||
path = self.config["path"]
|
||||
self.datas = []
|
||||
for f in os.listdir(path):
|
||||
if f.startswith("term_bank_") and f.endswith(".json"):
|
||||
with open(os.path.join(path, f), "r", encoding="utf8") as ff:
|
||||
self.datas += json.loads(ff.read())
|
||||
|
||||
def search(self, word):
|
||||
results = []
|
||||
diss = {}
|
||||
import winsharedutils
|
||||
|
||||
for item in self.datas:
|
||||
dis = winsharedutils.distance(item[0], word)
|
||||
if dis <= self.config["distance"]:
|
||||
results.append(item)
|
||||
diss[item[0]] = dis
|
||||
if len(results) == 0:
|
||||
return
|
||||
results = sorted(results, key=lambda x: diss[x[0]])
|
||||
|
||||
html = ""
|
||||
for item in results:
|
||||
word = item[0]
|
||||
hira = item[1]
|
||||
explain = item[5][0].replace("\n", "<br>")
|
||||
html += f'<tr><td><font color="#FF0000" size=5>{word}</font>{hira}</td></tr><tr><td>{explain}</td></tr>'
|
||||
html = f"<table><tbody>{html}</tbody></table>"
|
||||
# print(html)
|
||||
return html
|
@ -1023,36 +1023,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"yomichan": {
|
||||
"use": false,
|
||||
"name": "yomichan termbank",
|
||||
"args": {
|
||||
"path": "",
|
||||
"distance": 0,
|
||||
"priority": 100
|
||||
},
|
||||
"argstype": {
|
||||
"path": {
|
||||
"type": "file",
|
||||
"name": "路径",
|
||||
"dir": true
|
||||
},
|
||||
"distance": {
|
||||
"type": "intspin",
|
||||
"name": "模糊匹配_编辑距离",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
},
|
||||
"priority": {
|
||||
"type": "intspin",
|
||||
"name": "优先级",
|
||||
"min": 0,
|
||||
"max": 10000,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"goo": {
|
||||
"use": false,
|
||||
"name": "goo",
|
||||
|
Loading…
x
Reference in New Issue
Block a user