#' show in-ing en-eng pair sound words
#' @author lgm
#' @param shengMu a sheng mu vector
#' @param yunMU a yunMu vector
#' @return words all possible pairs of words with the combination of sheng mu and yun mu
#' @export
#' @examples
#' ing <- c('in','ing')
#' eng <- c('en','eng')
#' pre_ing <- c('b','d','j','l','m','n','p','y')
#' pre_eng <- c('b','c','ch','d','f','g','k','m','n','p','s','sh','w','z','zh')
#' show_ng_pair_sound(pre_ing,ing)
#' show_ng_pair_sound(pre_eng,eng)
show_ng_pair_sound <- function(shengMu,yunMU){
# combine two pairs using expand.grid
con <- sort(apply(expand.grid(shengMu, yunMU), 1, paste, collapse = "", sep = ""))
#con
# 将一个向量分成由2个向量组成的list
res = list()
for (i in seq(1,length(con),by=2)) {
res =c(res,list(c(con[i],con[i+1])))
}
#dput(res)
gmdata::compare_pinyin(res)
}
show_in_en <- function(input = 'in'){
ing <- c('in','ing')
eng <- c('en','eng')
pre_ing <- c('b','d','j','l','m','n','p','q','x','y')
pre_eng <- c('b','c','ch','d','f','g','k','m','n','p','s','sh','w','z','zh')
c = c('c','ch')
suf_ch = c('a','ai','an','ang','ao','e','en','eng','i','ong','u','ou','uo','ui','uan','un')
if(input == 'in')
{show_ng_pair_sound(pre_ing,ing)
} else if(input == 'en') {
show_ng_pair_sound(pre_eng,eng)
} else if (input=='c') {
show_ng_pair_sound(c,suf_ch)
}
}
# compare_pinyin(list(c('zuo','zhuo'),c('za','zha'),c('zi','zhi'),c('zui','zhui'),c('ze','zhe'),c('zu','zhu'),c('zi','zhi'),c('zou','zhou'),c('zao','zhao'),c('zan','zhan'),c('zai','zhai'),c('zei','zhei')))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.