Android realizes the function of converting Chinese characters to Pinyin with multi tone word recognition

Android Chinese character to Pinyin with multi tone word recognition function for your reference. The specific contents are as follows

Problem source

There is such a bug when sorting place names by initials. Changsha will be translated into zhangsha and Chongqing into Zhong Qing. So the ranking went wrong.

Chinese character to Pinyin library and multi tone character recognition library 1. Vocabulary library corresponding to multi tone characters 2. Pinyin library corresponding to binary size of characters

critical code

1. Here, I first convert the text to be converted into the corresponding "GB2312" code. The conversion of Chinese characters into binary code generally takes two bytes. If one byte returns characters, if it is two bytes, calculate the offset. The code is as follows

2. Compare the Pinyin obtained from a single Chinese character with the HashMap of the multi tone word library. The code is as follows:

3. Parse the contents of the assets file to generate a HashMap list

GitHub source code download: https://github.com/loveburce/ChinesePolyphone.git

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>