mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
termbank
Update LunaTranslator.py
This commit is contained in:
parent
0444020284
commit
6f5063f827
@ -452,7 +452,6 @@ class MAINUI:
|
|||||||
if globalconfig["sourcestatus2"]["texthook"]["use"]:
|
if globalconfig["sourcestatus2"]["texthook"]["use"]:
|
||||||
self.textsource = texthook(pids, hwnd, pexe)
|
self.textsource = texthook(pids, hwnd, pexe)
|
||||||
|
|
||||||
# @threader
|
|
||||||
def starttextsource(self, use=None, checked=True):
|
def starttextsource(self, use=None, checked=True):
|
||||||
self.translation_ui.showhidestate = False
|
self.translation_ui.showhidestate = False
|
||||||
self.translation_ui.refreshtooliconsignal.emit()
|
self.translation_ui.refreshtooliconsignal.emit()
|
||||||
@ -547,6 +546,7 @@ class MAINUI:
|
|||||||
return None
|
return None
|
||||||
return aclass(classname)
|
return aclass(classname)
|
||||||
|
|
||||||
|
@threader
|
||||||
def prepare(self, now=None, _=None):
|
def prepare(self, now=None, _=None):
|
||||||
self.commonloader("fanyi", self.translators, self.fanyiinitmethod, now)
|
self.commonloader("fanyi", self.translators, self.fanyiinitmethod, now)
|
||||||
|
|
||||||
@ -574,6 +574,7 @@ class MAINUI:
|
|||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
|
|
||||||
|
@threader
|
||||||
def startxiaoxueguan(self, type_=None, _=None):
|
def startxiaoxueguan(self, type_=None, _=None):
|
||||||
self.commonloader("cishu", self.cishus, self.cishuinitmethod, type_)
|
self.commonloader("cishu", self.cishus, self.cishuinitmethod, type_)
|
||||||
|
|
||||||
|
41
LunaTranslator/LunaTranslator/cishu/yomichan.py
Normal file
41
LunaTranslator/LunaTranslator/cishu/yomichan.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
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):
|
||||||
|
best=[]
|
||||||
|
normal=[]
|
||||||
|
bad=[]
|
||||||
|
for item in self.datas:
|
||||||
|
if item[0]==word:
|
||||||
|
best.append(item)
|
||||||
|
elif item[0].startswith(word) or item[0].endswith(word):
|
||||||
|
normal.append(item)
|
||||||
|
elif word in item[0]:
|
||||||
|
bad.append(item)
|
||||||
|
|
||||||
|
if len(bad)+len(best)+len(normal)==0:return
|
||||||
|
html=''
|
||||||
|
for item in best+normal+bad:
|
||||||
|
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
|
@ -894,6 +894,28 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"yomichan": {
|
||||||
|
"use": false,
|
||||||
|
"name": "yomichan termbank",
|
||||||
|
"args": {
|
||||||
|
"path": "",
|
||||||
|
"priority": 100
|
||||||
|
},
|
||||||
|
"argstype": {
|
||||||
|
"path": {
|
||||||
|
"type": "file",
|
||||||
|
"name": "路径",
|
||||||
|
"dir": true
|
||||||
|
},
|
||||||
|
"priority": {
|
||||||
|
"type": "intspin",
|
||||||
|
"name": "优先级",
|
||||||
|
"min": 0,
|
||||||
|
"max": 10000,
|
||||||
|
"step": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"goo": {
|
"goo": {
|
||||||
"use": false,
|
"use": false,
|
||||||
"name": "goo",
|
"name": "goo",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user