Skip to content

Commit 62af779

Browse files
committed
trivial
1 parent 020ba8c commit 62af779

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

init_mdict_path.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,30 @@
2828
root.withdraw() # 隐藏主界面
2929

3030
_path = askdirectory()
31-
config.update({'mdict_path': [_path]})
32-
print('mdict_path', _path)
31+
# 如果用户点击取消和关闭选择框,返回值都是空字符串。
32+
if _path != '':
33+
config.update({'mdict_path': [_path]})
34+
print('mdict_path', _path)
35+
else:
36+
print('mdict_path is empty.')
3337
_path = askdirectory()
34-
# 如果用户关闭了选择框,那么返回值是什么?
35-
config.update({'audio_path': [_path]})
36-
print('audio_path', _path)
38+
if _path != '':
39+
config.update({'audio_path': [_path]})
40+
print('audio_path', _path)
41+
else:
42+
print('audio_path is empty.')
3743
else:
3844
if mdict_path != '':
3945
config.update({'mdict_path': [mdict_path]})
46+
print('mdict_path', mdict_path)
47+
else:
48+
print('mdict_path is empty. require -m parameter, use -h to show help.')
49+
4050
if audio_path != '':
4151
config.update({'audio_path': [audio_path]})
42-
43-
if mdict_path == '' and audio_path == '':
44-
print('require -m or -a parameter, use -h to show help.')
52+
print('audio_path', audio_path)
53+
else:
54+
print('audio_path is empty.')
4555

4656

4757
def write_json_file(con, file, mode='w'):

mdict/mdict_utils/search_utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import re
44

55
from django.db.models.functions import Length
6-
from nltk.data import path as nltk_path
7-
from nltk.stem import WordNetLemmatizer
86
from spellchecker import SpellChecker
97

108
from base.base_utils import ROOT_DIR
@@ -28,6 +26,8 @@
2826
# thpool = create_thread_pool()
2927

3028
try:
29+
from nltk.data import path as nltk_path
30+
from nltk.stem import WordNetLemmatizer
3131
nltk_path.append(os.path.join(ROOT_DIR, 'media', 'nltk_data'))
3232
lemmatizer = WordNetLemmatizer()
3333
lemmatizer.lemmatize('a')

0 commit comments

Comments
 (0)