【发布时间】:2018-10-07 11:21:12
【问题描述】:
我有拉丁词的数据集
text<-c("TESS",
"MAG")
我想设置拉丁西里尔字母的音译
library(stringi)
d=stri_trans_general(mydat$text, "latin-cyrillic")
但我想手动创建转译字典。 例如:
dictionary<-c("Tess"="ТЕСС"
"MAG"="МАГ"
.......
......
)
创建字典时, 在 mydat$text 中,所有拉丁词都必须替换为我设置的西里尔字母。 像这样的
d=dictionary(mydat$text)
如何进行这种替换?
输入
text<-c("TESS",
"MAG")
带翻译的文件
dict=path.csv
里面有
dict=
structure(list(old = structure(c(2L, 1L), .Label = c("mag", "tess"
), class = "factor"), new = structure(c(2L, 1L), .Label = c("маг",
"тесс"), class = "factor")), .Names = c("old", "new"), class = "data.frame", row.names = c(NA,
-2L))
#输出
text<-c("ТЕСС",
"МАГ")
就是这样
【问题讨论】:
-
类似
setNames(stri_trans_general(mydat$text, "latin-cyrillic"), mydat$text)? -
@Moody_Mudskipper,我的字典在哪里?
-
假设。我在文件 dict.csv 中的字典
-
我不清楚你想要什么,你能编辑你的帖子并明确说明你的确切输入是什么,你的确切输出是什么?
-
@Moody_Mudskipper,我编辑了帖子,请检查