def chkcntxt():
oldwords = textPad.get(1.0, END)
# d.SpellChecker("en_US") https://blog.csdn.net/hpulfc/article/details/80997252
apiidchk='27213257'
APIKey_wordchk = 'LkUF1O3NmssOQDB6RvnWkwy2'
secretKey_wordchk = "dC373FcA7o62rPQSHL1WI0WIgjD42nmO"
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=LkUF1O3NmssOQDB6RvnWkwy2&client_secret=dC373FcA7o62rPQSHL1WI0WIgjD42nmO'
response_token = requests.get(host)
token = response_token.json()['access_token']
print(token)
url = 'https://aip.baidubce.com/rpc/2.0/nlp/v1/ecnet?access_token=' + token
#https://aip.baidubce.com/rpc/2.0/nlp/v1/lexer?charset=UTF-8&access_token=24.f9ba9c5241b67688bb4adbed8bc91dec.2592000.1485570332.282335-8574074
headers = {'Content-Type': 'application/json'}
payload = {'text': oldwords, }
r = requests.post(url,params=payload, headers=headers)
result = r.json()
result2='可能是:\n'+result['item']['correct_query']
print(result2)
# chkr = SpellChecker("en_US")
# chkr.set_text(oldwords)
# textPad3fanyi.delete(0.0, 'end')
# for err in chkr:
# print("ERROR", err.word)
# showerr = "ERROR", err.word, '\n'
# textPad3fanyi.insert('end', showerr)
# now1 = textPad3fanyi.get(1.0, END).replace('}', '').replace(' {', '')
textPad3fanyi.delete(0.0, 'end')
textPad3fanyi.insert('end', result2)
# https://www.jc2182.com/python/python-text-translation.html
showinfo('notice', '纠正后内容显示在 翻译区.')
def chkspell():
import enchant
from enchant.checker import SpellChecker
oldwords = textPad.get(1.0, END)
chkr = enchant.Dict("en_US")
# d.SpellChecker("en_US") https://blog.csdn.net/hpulfc/article/details/80997252
chkr = SpellChecker("en_US")
chkr.set_text(oldwords)
textPad3fanyi.delete(0.0, 'end')
for err in chkr:
print ("ERROR", err.word)
showerr="ERROR", err.word,'\n'
textPad3fanyi.insert('end', showerr)
now1=textPad3fanyi.get(1.0, END).replace('}','').replace(' {','')
textPad3fanyi.delete(0.0, 'end')
textPad3fanyi.insert('end', now1)
# https://www.jc2182.com/python/python-text-translation.html
showinfo('notice','拼写错误的英语单词显示在 翻译区.')
Rogabet-note高级版2022830链接:https://pan.baidu.com/s/1E_8uJ5KuUY9dlH309MdaGw?pwd=0830