Title: | Convert Chinese Characters into Pinyin, Sijiao, Wubi or Other Codes |
---|---|
Description: | Convert Chinese characters into Pinyin (the official romanization system for Standard Chinese in mainland China, Malaysia, Singapore, and Taiwan. See <https://en.wikipedia.org/wiki/Pinyin> for details), Sijiao (four or five numerical digits per character. See <https://en.wikipedia.org/wiki/Four-Corner_Method>.), Wubi (an input method with five strokes. See <https://en.wikipedia.org/wiki/Wubi_method>) or user-defined codes. |
Authors: | Peng Zhao [aut, cre], Qu Cheng [ctb], TC Zhang [ctb] |
Maintainer: | Peng Zhao <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.7 |
Built: | 2024-11-17 02:53:16 UTC |
Source: | https://github.com/pzhaonet/pinyin |
Convert strings of Chinese characters into Pinyin.
as.pinyin(char, sep = "_", other_replace = NULL, dic = pinyin::pinyin2)
as.pinyin(char, sep = "_", other_replace = NULL, dic = pinyin::pinyin2)
char |
Requrired A input character string with chinese characters. |
sep |
character The seperator between the converted pinyin. Default: '_' |
other_replace |
character The replacement for non-Chinese characters |
dic |
The preloaded dictionary for conversion. Default: "pinyin::pinyin2" |
A character vector of the converted pinyin string.
py("hello word")
py("hello word")
Convert the Chinese headers of bookdown .Rmd files into Pinyin
bookdown2py( folder = "py", remove_curly_bracket = TRUE, other_replace = NULL, dic = NA )
bookdown2py( folder = "py", remove_curly_bracket = TRUE, other_replace = NULL, dic = NA )
folder |
character. The folder in which the files are to be converted. |
remove_curly_bracket |
logical. Whether to remove existing curly brackets in the headers. |
other_replace |
NULL or character. Define how to convert non-Chinese characters in mychar. NULL means 'let it be'. |
dic |
See |
new .Rmd files with Pinyin headers.
bookdown2py(dic = NA)
bookdown2py(dic = NA)
Rename files according to a given dictionary
file.rename2py(folder = "py", dic = NA)
file.rename2py(folder = "py", dic = NA)
folder |
character. The folder in which the files are to be renamed. |
dic |
See |
files with new names.
file.rename2py(dic = NA)
file.rename2py(dic = NA)
Convert the characters in an entire files according to a given dictionary
file2py( folder = "py", backup = TRUE, sep = " ", other_replace = NULL, encoding = "UTF-8", dic = NA )
file2py( folder = "py", backup = TRUE, sep = " ", other_replace = NULL, encoding = "UTF-8", dic = NA )
folder |
character. The folder in which the files are to be converted. |
backup |
logical. Whether the original files should be saved as backups. |
sep |
character. Seperation between the converted pinyin. |
other_replace |
NULL or character. Define how to convert non-Chinese characters in mychar. NULL means 'let it be'. |
encoding |
character. The encoding of the input files. 'UTF-8' by default. |
dic |
See |
files converted to Pinyin.
file2py(dic = NA)
file2py(dic = NA)
Title insert a character(s) before all lattin letters in a string
insert(oldchar, insertchar = ",")
insert(oldchar, insertchar = ",")
oldchar |
the old string |
insertchar |
the character(s) to insert |
a new string
Load a customized dictionary.
load_dic(dic_file = NA, select = 1)
load_dic(dic_file = NA, select = 1)
dic_file |
The path of a dictionary file. |
select |
The option to choose from the dictionary. |
A dictionary
load_dic()
load_dic()
Former version of py()
pinyin()
pinyin()
a message
pinyin()
pinyin()
A dataset containing the Chinese characters and the corresponding pinyin, Source: A friend of dapeng
pinyin2
pinyin2
A data frame with 20520 rows and 2 variables:
a chinese character
a pinyin
...
Convert strings of Chinese characters into Pinyin.
py(char = "", sep = "_", other_replace = NULL, dic = pydic())
py(char = "", sep = "_", other_replace = NULL, dic = pydic())
char |
a string vector |
sep |
character. Seperation between the converted pinyin. |
other_replace |
NULL or character. Define how to convert non-Chinese characters in mychar. NULL means 'let it be'. |
dic |
the preloaded pinyin library using the |
pinyin of the given Chinese string.
py(dic = NA)
py(dic = NA)
Convert a string of Chinese characters into Pinyin.
py_single(char = "", sep = "_", other_replace = NULL, dic = pydic())
py_single(char = "", sep = "_", other_replace = NULL, dic = pydic())
char |
character. A Chinese character or string to convert to pinyin |
sep |
character. Seperation between the converted pinyin. |
other_replace |
NULL or character. Define how to convert non-Chinese characters in mychar. NULL means 'let it be'. |
dic |
the preloaded pinyin library using the |
pinyin of the given Chinese string.
Load a Pinyin library
pydic( method = c("quanpin", "tone", "toneless"), multi = FALSE, only_first_letter = FALSE, dic = c("pinyin", "pinyin2") )
pydic( method = c("quanpin", "tone", "toneless"), multi = FALSE, only_first_letter = FALSE, dic = c("pinyin", "pinyin2") )
method |
character. The value can be:
|
multi |
logical. Whether display multiple pronounciations of a Chinese character or only the first pronounciation. |
only_first_letter |
logical. Wheter only the first letter in pinyin. |
dic |
character. Choose the dictionary. |
character. a Pinyin library.
pydic()
pydic()
split a string and extract the nth string
strsplit2(x, sep = " ", nth = 1)
strsplit2(x, sep = " ", nth = 1)
x |
The string to split |
sep |
The separated character |
nth |
The nth string to extract |
a new string