配合有道翻译自动译文

import requests
import pandas as pd

def main(query):
    url = 'http://fanyi.youdao.com/translate'
    data = {
        "i": query,  # 待翻译的字符串
        "from": "AUTO",
        "to": "AUTO",
        "smartresult": "dict",
        "client": "fanyideskweb",
        "salt": "16081210430989",
        "doctype": "json",
        "version": "2.1",
        "keyfrom": "fanyi.web",
        "action": "FY_BY_CLICKBUTTION"
    }
    res = requests.post(url, data=data).json()
    # print(res)
    return res
    # print(res['translateResult'][0][0]['tgt'])  # 打印翻译后的结果

main('我')
main('In vitro studies inhibiting ATP1A1 expression in HT-144, G-361, C-32 and SKMEL-28 melanoma cell lines demonstrated ATP1A1 overexpression is activating as measured by reduced tumor growth upon ATP1A1 inhibition. Tumor cells expressing amplified ATP1A1 demonstrated sensitivity when treated with ATP1A1 inhibitor UNBS1450 and antioxidant N-acetyl cysteine (PMID: 26334094, 19243476).')

# {'type': 'EN2ZH_CN', 'errorCode': 0, 'elapsedTime': 4, 'translateResult': [[{'src': 'In vitro studies inhibiting ATP1A1 expression in HT-144, G-361, C-32 and SKMEL-28 melanoma cell lines demonstrated ATP1A1 overexpression is activating as measured by reduced tumor growth upon ATP1A1 inhibition. ', 'tgt': '体外研究抑制ATP1A1表达ht - 144 c - 32 g - 361和SKMEL-28黑色素瘤细胞系证明ATP1A1过度激活以减少对ATP1A1抑制肿瘤的生长。'}, {'src': 'Tumor cells expressing amplified ATP1A1 demonstrated sensitivity when treated with ATP1A1 inhibitor UNBS1450 and antioxidant N-acetyl cysteine (PMID: 26334094, 19243476).', 'tgt': '肿瘤细胞表达放大ATP1A1证明灵敏度时接受UNBS1450 ATP1A1抑制剂和抗氧化剂n -乙酰半胱氨酸(PMID: 26334094、19243476)。'}]]}

df1=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='oncokb')
df2=pd.read_excel(r'C:\Users\Administrator\Desktop\search\CNV数据库(1).xlsx',sheet_name='ckb')

for i in range(len(df1)):
    if pd.isnull(df1.loc[i,'Interpretation']) == False:
        list_all = main(df1.loc[i, 'Interpretation'])['translateResult'][0]
        text_last=''
        for j in list_all:
            text_add=j['tgt']
            text_last += text_add

        df1.loc[i,'chinese']=text_last
    else:
        pass

new_wb=pd.ExcelWriter(r'C:\Users\Administrator\Desktop\search\CNV数据库_update.xlsx')
df1.to_excel(new_wb,sheet_name='oncokb',index=None)
df2.to_excel(new_wb,sheet_name='ckb',index=None)

#new_wb.save()
new_wb.close()
  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值