csharp-pinyin is a lightweight Chinese/Cantonese to Pinyin library.
Chinese dialects can be used to create their own dictionaries using makedict.
Initial version algorithm reference zh_CN, and undergo significant optimization.
pinyin-makedict is the tool for creating Chinese/Cantonese dictionaries.
Interface reference pypinyin
Only Unicode within the range of [ 0x4E00 - 0x9FFF ] is supported.
Segmentation for heteronym words.
Support Traditional and Simplified Chinese.
Speed is very fast, about 500,000 words/s.
Achieved an accuracy rate of 99.9% on a 200000 word Lyrics-Pinyin test set Without-Tone.
The With-Tone test on CPP_Dataset(about 79k sentences) achieved an accuracy of 90.3%, while the accuracy of pypinyin was approximately 87%.
usingPinyin;Pinyin.PinyinpinyinInstance=Pinyin.Pinyin.Instance;// or Pinyin.Jyutping.Instance;stringhans="明月@1几32时有##一";PinyinResVectorpinyinRes=pinyinInstance.HanziToPinyin(key,ManTone.Style.NORMAL,Error.Default,false,false,false);List<string>pinyin=pinyinInstance.GetDefaultPinyin("了",ManTone.Style.TONE3,false,false);// include/ChineseG2p.cspublicstructPinyinRes{publicstringhanzi;// utf-16 stringpublicstringpinyin;// utf-16 stringpublicList<string>candidates;// Candidate pinyin of Polyphonic Characters.publicboolerror;// Whether the conversion failed.};
publicclassPinyinResList:List<PinyinRes>{public:// Convert to utf-16 string list.publicList<string>ToStrList();// Convert to utf-16 string with delimiter(default: " ").publicstringToStr(stringdelimiter=" ");};
// ChineseG2p.csenumclass Error {// Keep original charactersDefault=0,// Ignore this character (do not export)Ignore=1};
/* @param hans : raw utf-16 string. @param ManTone.Style : Preserve the pinyin tone. @param errorType : Ignore words that have failed conversion. Default: Keep original. @param candidates : Return all possible pinyin candidates. Default: true. @param v_to_u : Convert v to ü. Default: false. @param neutral_tone_with_five : Use 5 as neutral tone. Default: false. @return PinyinResList.*/publicPinyinResListHanziToPinyin(stringhans,ManTone.Stylestyle=ManTone.Style.TONE,Errorerror=Error.Default,boolcandidates=true,boolvToU=false,boolneutralToneWithFive=false);/* @param hans : raw utf-16 List<string>, each element of the vector is a character. ... @return PinyinResList.*/publicPinyinResListHanziToPinyin(List<string>hans,ManTone.Stylestyle=ManTone.Style.TONE,Errorerror=Error.Default,boolcandidates=true,boolvToU=false,boolneutralToneWithFive=false);// Convert to Simplified Chinese. utf-8 std::stringstringTradToSim(stringtext);// Determine if it is a polyphonic character.boolIsPolyphonic(stringtext);// Get a pronunciation list.publicList<string>GetDefaultPinyin(stringhanzi,ManTone.Stylestyle=ManTone.Style.TONE,boolvToU=false,boolneutralToneWithFive=false);zh_CN The core algorithm source has been further tailored to the dictionary in this project.
opencpop The test data source.
M4Singer The test data source.
cc-edict The dictionary source.
pinyin The fan-jian dictionary source.
cpp_dataset The cpp_dataset source.
pinyin-makedict A tool for creating Chinese/Cantonese dictionaries.
cpp-pinyin A C++ implementation of Chinese/Cantonese to Pinyin library.
python-pinyin A Python implementation of Chinese/Cantonese to Pinyin library.