Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Translate Words or Sentences via Online Translators

NotificationsYou must be signed in to change notification settings

YuLab-SMU/fanyi

Repository files navigation

Useful functions to translate text for multiple languages using onlinetranslators. For example, by translating error messages and descriptiveanalysis results into a language familiar to the user, it enables abetter understanding of the information, thereby reducing the barrierscaused by language. It offers several helper functions to query geneinformation to help interpretation of interested genes (e.g., markergenes, differential expression genes), and provides utilities totranslate ‘ggplot’ graphics. This package is not affiliated with any ofthe online translators. The developers do not take responsibility forthe invoice it incurs when using this package, especially for exceedingthe free quota.

To cite fanyi in publications use:

✍️ Authors

Guangchuang YU

School of Basic Medical Sciences, Southern Medical University

https://yulab-smu.top

⏬ Installation

Get the released version from CRAN:

install.packages("fanyi")

Or the development version from github:

## install.packages("yulab.utils")yulab.utils::install_zip_gh("YuLab-SMU/fanyi")

🔰 Usages

To switch between different online translators:

You should useset_translate_source() to set the default translatorused intranslate().

Alternatively, you can call specific functions to use a specifictranslator (e.g.,baidu_translate(),bing_translate(),youdao_translate(), etc.).

To usebaidu translate:

  1. go tohttps://fanyi-api.baidu.com/manage/developer and register asan individual developer
  2. enable通用文本翻译API service
  3. getappid andkey (密钥)
  4. setappid andkey withsource = "baidu" usingset_translate_option()
  5. have fun withbaidu_translate()

To usebing translate:

  1. register a free Azure account
  2. enableAzure AI services | Translator fromhttps://portal.azure.com/
  3. create a translation service with free tier pricing version (youneed a visa/master card to complete registration and will not becharged until you exceed 2 million characters monthly)
  4. get yourkey andregion
  5. setkey andregion withsource = "bing" usingset_translate_option()
  6. have fun withbing_translate()

To useyoudao (有道智云) translate:

  1. go tohttps://ai.youdao.com/ and register an account
  2. click自然语言翻译服务 and create an app from subsection文本翻译
  3. get your应用ID as appid, and应用秘钥 as key
  4. setappid andkey withsource = "youdao" usingset_translate_option()
  5. have fun withyoudao_translate()
  6. (bonus) you can also create术语表 (dictionary for the terms) as auser-defined dictionary and get the dict id to help you get precisetranslation in a certain domain.

To usevolcengine (火山引擎) translate:

  1. go tohttps://www.volcengine.com/ and register an account
  2. enableMachine Translation (机器翻译)
  3. get app key
    • click控制台
    • click your avatar at the upper-right corner
    • selectAPI访问密钥
    • click新建密钥
  4. for security concerns, you are highly advised to add a sub-account(新建子用户)
  5. click the subaccount name in身份管理 -用户, and clickpermissions (权限)
  6. inGlobal permissions (全局权限), add the following permissions:“TranslateFullAccess”, “I18nTranslateFullAccess”
  7. setappid andkey withsource = "volcengine" usingset_translate_option() and have fun withvolcengine_translate()

To usecaiyun (彩云小译) translate:

  1. go tohttps://platform.caiyunapp.com/login and register
  2. login with your account, create a translation app (创建应用)choose翻译 as接口类型
  3. get the token, set it as thekey withsource = "caiyun" usingset_translate_option()
  4. have fun withcaiyun_translate()
  5. caiyun currently supportsfrom = {zh(中文), en, ja(日语),auto(自动识别)} andto = {en, ja, zh}, defaultfrom isauto

To usetencent (腾讯机器翻译) translate:

  1. go tohttps://console.cloud.tencent.com and register;
  2. login with your account, go tohttps://console.cloud.tencent.com/tmt to enable machinetranslation (启用机器翻译);
  3. go tohttps://console.cloud.tencent.com/cam/user/userType, createa sub-account, inPermissions (权限) -Permissions policy(权限策略), search and addQcloudTMTFullAccess;
  4. get your API keys atAPI keys (API 密钥) of the same page instep 3. setSecretId as theappid andSecretKey assecretsrespectively withsource = "tencent" usingset_translate_option()
  5. have fun withtencent_translate()
  6. for supported languages, visithttps://cloud.tencent.com/document/product/551/15611 for moreinformation.

To usechatglm (智谱清言ChatGLM) translate:

  1. go tohttps://open.bigmodel.cn and register;
  2. login with your account, go tohttps://open.bigmodel.cn/usercenter/apikeys to get your API key;
  3. set the API key askey (no need for settingappid) withsource = "chatglm" usingset_translate_option()
  4. have fun withchatglm_translate()
  5. you can also set the model you prefer to use with the optionuser_model when usingset_translate_option(), currentlyuser_model can be set asglm-4 (by default),glm-4v,glm-3-turbo.

To useDeepSeek translate:

  1. go tohttps://platform.deepseek.com/ and register;
  2. login with your account, go tohttps://platform.deepseek.com/api_keys to get your API key;
  3. set the API key askey (no need for settingappid) withsource = "dsk" usingset_translate_option()
  4. have fun withdsk_translate()
  5. you can also set the model you prefer to use with the optionuser_model when usingset_translate_option(), currentlyuser_model can be set asdeepseek-chat (by default),deepseek-coder.

Helper functions:

  • gene_summary() retrieves gene information from NCBI.
  • translate_ggplot() translates axis labels of a ggplot graph.
  • ydict() queries words from the Youdao dictionary.

🉐 Examples

library(fanyi)#### run `set_translate_option()` to setup##text<-'我都不知道做人该怎么办,总之报纸写啥就信啥,电视演啥我就看啥。'
translate(text,from='zh',to='en')

I don’t even know what to do as a person. Anyway, I believe whateveris written in the newspaper and watch whatever is shown on TV.

translate(text,from='zh',to='th')

ผมไม่รู้ว่าการเป็นมนุษย์ควรทําอย่างไร สรุปแล้วหนังสือพิมพ์เขียนอะไรก็เชื่ออย่างนั้นทีวีเล่นอะไรก็อ่านอย่างนั้น

translate(text,from='zh',to='jp')

私は人間としてどうすればいいのか分からないが、とにかく新聞は何を書いても何を信じても、テレビは何を演じても私は何を見てもいい。

translate(text,from='zh',to='fra')

Je ne sais pas quoi faire en tant que personne, je crois ce que lesjournaux écrivent, je regarde ce que la télévision fait.

library(DOSE)library(enrichplot)data(geneList)de<- names(geneList)[1:200]x<- enrichDO(de)
p<- dotplot(x)p2<- translate_ggplot(p,axis='y')p3<- translate_ggplot(p,axis='y',to='kor')p4<- translate_ggplot(p,axis='y',to='ara')aplot::plot_list(English=p,Chinese=p2,Korean=p3,Arabic=p4,ncol=2)

ydict("cell")
    Explains: 细胞    Web: https://m.youdao.com/m/result?lang=en&word=cell
symbol<- c("CCR7","CD3E")gene<-clusterProfiler::bitr(symbol,fromType='SYMBOL',toType='ENTREZID',OrgDb='org.Hs.eg.db')gene
  SYMBOL ENTREZID1   CCR7     12362   CD3E      916
res<- gene_summary(gene$ENTREZID)names(res)
[1] "uid"         "name"        "description" "summary"
d<-data.frame(desc=res$description,desc2=translate(res$description))d
                                            desc                   desc21                 C-C motif chemokine receptor 7    C-C基序趋化因子受体72 CD3 epsilon subunit of T-cell receptor complex T细胞受体复合物CD3ε亚基
res$summary

[1] The protein encoded by this gene is a member of the Gprotein-coupled receptor family. This receptor was identified as agene induced by the Epstein-Barr virus (EBV), and is thought to be amediator of EBV effects on B lymphocytes. This receptor is expressedin various lymphoid tissues and activates B and T lymphocytes. It hasbeen shown to control the migration of memory T cells to inflamedtissues, as well as stimulate dendritic cell maturation. The chemokine(C-C motif) ligand 19 (CCL19/ECL) has been reported to be a specificligand of this receptor. Signals mediated by this receptor regulate Tcell homeostasis in lymph nodes, and may also function in theactivation and polarization of T cells, and in chronic inflammationpathogenesis. Alternative splicing of this gene results in multipletranscript variants. [provided by RefSeq, Sep 2014]

[2] The protein encoded by this gene is the CD3-epsilon polypeptide,which together with CD3-gamma, -delta and -zeta, and the T-cellreceptor alpha/beta and gamma/delta heterodimers, forms the T-cellreceptor-CD3 complex. This complex plays an important role in couplingantigen recognition to several intracellular signal-transductionpathways. The genes encoding the epsilon, gamma and delta polypeptidesare located in the same cluster on chromosome 11. The epsilonpolypeptide plays an essential role in T-cell development. Defects inthis gene cause immunodeficiency. This gene has also been linked to asusceptibility to type I diabetes in women. [provided by RefSeq, Jul2008]

translate(res$summary)

[1]该基因编码的蛋白质是G蛋白偶联受体家族的成员。该受体被鉴定为由爱泼斯坦-巴尔病毒(EBV)诱导的基因,被认为是EBV对B淋巴细胞影响的介质。这种受体在各种淋巴组织中表达,并激活B和T淋巴细胞。它已被证明可以控制记忆T细胞向炎症组织的迁移,并刺激树突细胞成熟。趋化因子(C-C基序)配体19(CCL19/ECL)已被报道为该受体的特异性配体。由该受体介导的信号调节淋巴结中的T细胞稳态,也可能在T细胞的活化和极化以及慢性炎症发病机制中发挥作用。该基因的选择性剪接导致多种转录变体。【由RefSeq提供,2014年9月】

[2]该基因编码的蛋白质是CD3ε多肽,它与CD3γ、δ和ζ以及T细胞受体α/β和γ/δ异二聚体一起形成T细胞受体-CD3复合物。该复合物在将抗原识别与几种细胞内信号转导通路偶联方面起着重要作用。编码ε、γ和δ多肽的基因位于11号染色体上的同一簇中。ε多肽在T细胞发育中起着至关重要的作用。这种基因的缺陷会导致免疫缺陷。该基因也与女性患I型糖尿病的易感性有关。【由RefSeq提供,2008年7月】

📖 Documents

About

Translate Words or Sentences via Online Translators

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp