一种将墨墨单词导入QWERTY-LEARNER的方法
下载装有墨墨词库的数据库
https://download.csdn.net/download/xiaoyue2019/87300976
通过SQL语句导出词库:
1
2
3
4
5
6
7
8
9
10SELECT title,spelling,phonetic_uk,phonetic_us,difficulty,frequency,acknowledge_rate,study_user_count,`order`
FROM VOC_TB
INNER JOIN (
SELECT title,voc_origin_id,chapter_origin_id,`order`
FROM BK_VOC_TB V
INNER JOIN BK_CHAPTER_TB C ON V.chapter_origin_id= C.id AND V.book_origin_id IN (
SELECT origin_id
FROM BK_TB
WHERE name LIKE'%雅思词汇真经%')) AS tmp ON VOC_TB.origin_id=tmp.voc_origin_id
ORDER BY `order`将发音字段改名:
to–>1
2"ukphone": "[ˈɪmɪnənt]",
"usphone": "[ˈɪmənənt]",通过脚本添加翻译(调用百度翻译api)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54#百度通用翻译API,不包含词典、tts语音合成等资源,如有相关需求请联系translate_api@baidu.com
# coding=utf-8
import http.client
import hashlib
import urllib
import random
import json
def translate(q='apple'):
appid = '' # 填写你的appid
secretKey = '' # 填写你的密钥
httpClient = None
myurl = '/api/trans/vip/translate'
fromLang = 'auto' #原文语种
toLang = 'zh' #译文语种
salt = random.randint(32768, 65536)
sign = appid + q + str(salt) + secretKey
sign = hashlib.md5(sign.encode()).hexdigest()
myurl = myurl + '?appid=' + appid + '&q=' + urllib.parse.quote(q) + '&from=' + fromLang + '&to=' + toLang + '&salt=' + str(
salt) + '&sign=' + sign
try:
httpClient = http.client.HTTPConnection('api.fanyi.baidu.com')
httpClient.request('GET', myurl)
# response是HTTPResponse对象
response = httpClient.getresponse()
result_all = response.read().decode("utf-8")
result = json.loads(result_all)
return result['trans_result'][0]["dst"]
except Exception as e:
print (e)
finally:
if httpClient:
httpClient.close()
data = []
with open("./IELTS.json","r") as r:
rig_data = json.loads(r.read())
for i in rig_data:
tran = translate(i['name'])
i['trans'] = tran
data.append(i)
print(i)
with open("./NEW_IELTS.json","w") as w:
w.write(json.dumps(data))测试使用
可能的坑点
需要把多余字段删掉
…