Skip to content

Commit

Permalink
修复了翻译和日典功能的BUG
Browse files Browse the repository at this point in the history
关掉了对DeepL的翻译支持
日典功能增加对新版页面的支持
  • Loading branch information
Angel-Hair committed Apr 20, 2020
1 parent 47cd828 commit fe738bd
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# XUN_beta8.8
# XUN_beta9.1

## 介绍

Expand Down
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
MAXINFO_REIMU = 3 # 上车功能查找目的地的最大数 | 类型为int>0
MAXINFO_ANIME = 4 # 搜番功能查找番剧的最大数 | 类型为int>0
MAXLINE_JD = 7 # 日语词典功能查找条目的内容所允许的最大行书 | 类型为int>0
MAXWOED_JD = 300 # 日语词典功能查找条目的内容所允许的最大字数 | 类型为int>0
MAXWOED_JD = 250 # 日语词典功能查找条目的内容所允许的最大字数 | 类型为int>0

# TimeLimit类
TIMELIMIT_IMAGE = 7 # 识图功能的时间限制 | 类型为float
Expand Down
4 changes: 2 additions & 2 deletions include/plugins/japanese_dictionary/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_definition_of_word(word: str) -> str:
if notfound:
return notfound[0]

source = html.xpath('//div[@class="pbarTL"]/a/text()')
source = html.xpath('//div[@class="pbarTL"]')
definition = []
d_html = html.xpath('//div[@class="kiji"]')
for d in d_html:
Expand Down Expand Up @@ -49,7 +49,7 @@ async def get_definition_of_word(word: str) -> str:
d = d[:MAXWOED_JD].strip()
if line_is_hidden:
d += "……\n[Note]……有内容被省略……"
putline.append("【{}】\n{}".format(s,d))
putline.append("【{}】\n{}".format(s.xpath('string(.)').strip(),d))
repass = "\n\n".join(putline)
if is_hidden:
repass += "\n\n[Note]有条目过长被省略,更多释义请参考: {}".format(url)
Expand Down
4 changes: 0 additions & 4 deletions include/plugins/translation/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import sys

from googletrans import Translator
from pydeeplator.deepL import DeepLTranslator
from pydeeplator.deepL import TranslateLanguageEnum, TranslateModeType

sys.path.append('../../../')
from config import TIMELIMIT_TRANSL, BAIDUAPPID_TRANSL, BAIDUKEY_TRANSL, TO_TRANSL
Expand Down Expand Up @@ -57,8 +55,6 @@ async def get_transl_of_content(content: str) -> str:

transl_d['Google 翻译'] = google_translator.translate(content, dest = TO_TRANSL).text
transl_d['Baidu 翻译'] = baidu_translator(content, BAIDUAPPID_TRANSL, BAIDUKEY_TRANSL, 'auto', TO_TRANSL[:2])
if TO_TRANSL[:2] == 'zh':
transl_d['DeepL 翻译'] = deepl_translator(content)

repass = ""
putline = []
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ requests==2.22.0
lxml==4.4.1
thulac==0.2.1
kth-timeoutdecorator==0.0.5
googletrans==2.4.0
pydeeplator==0.0.1
googletrans==2.4.0

0 comments on commit fe738bd

Please sign in to comment.