R/evernote_wrong_sound_word.R

Defines functions evernote_wrong_sound_word

Documented in evernote_wrong_sound_word

#' add my wrong sound Chinese characters into evernote
#' @description insert some sound wrongly words into evernote and review them easily
#' @author lgm
#' @param word a easily wrong sound
#' @return cat some results which can be copied into evernot
#' @export
#' @examples
#' evernote_wrong_sound_word('荷')
#' evernote_wrong_sound_word('奔')
#' evernote_wrong_sound_word('于')

## append the results of a wrong sound word into Evernote
evernote_wrong_sound_word <- function(wrongWord){

	# create a new file to store the wrong sound words which can't be destoryed after every package update.
	wfile <- '~/Dropbox/my-wrong-sound-words.txt'
	#cat("",file = wfile, append = TRUE)

	cat(paste0(Sys.Date(),'易错词: ',wrongWord,'\n\n')) # note title

	cat('同音词:\n')
	w <- gmdata::search_easy_mistake(wrongWord,onlyTheWord = TRUE)
	cat(w[[1]])

  cat('\n\n') #print an empty line

	w2 <- dplyr::mutate(w[[2]],wpy = paste(word,pinyin)) %>% dplyr::select(wpy)
	wordtable <- matrix(as.matrix(w2),ncol = 6) %>% as.data.frame()
	names(wordtable) <- NULL

	# get the explain of the word
	ex <- search_word_online(wrongWord, ret=TRUE) %>%
		gsub('\n\n笔画数.+$','',.) %>%
		gsub('\r\n\r\n','\r\n',.)
	cat(ex)
	cat('\n\n')

	#expl <- cat(search_word_online(wrongWord, ret=TRUE))

	return(list(词语 = wordtable))
}
Gabegit/gmdata documentation built on May 6, 2019, 5:32 p.m.