Android--jpinyin class

Source: Internet
Author: User


Search for Chinese characters-----need to return the letter of each person's name on the server side

The method of extracting pinyin from Android Chinese characters J

http://blog.csdn.net/tanranran/article/details/44173471

First, Introduction

Project Address: Https://github.com/stuxuhai/jpinyin

Jpinyin is a kind of Java open source class library of Chinese characters to pinyin, and has made some improvements on the basis of pinyin4j function.

"Jpinyin Main Features"
1, accurate, perfect font;
Unicode encoding from the 4e00-9fa5 range and 3007 (0) of the 20,903 Chinese characters, Jpinyin can convert all the Chinese characters except the 46 allogeneic words (the non-standard pinyin);
2, pinyin conversion speed fast;
After testing, the conversion of Unicode encoding from the 4e00-9fa5 range of 20,902 Kanji, Jpinyin takes about 100 milliseconds.
3, multi-pinyin format output support;
Jpinyin supports a variety of pinyin output formats: bands, non-bands, digital representation of phonetic transcription, and pinyin first letter output format;
4, common polyphone recognition;
Jpinyin supports the identification of common polyphone, including phrases, idioms, place names, etc.;
5, simplified Traditional Chinese conversion

Jpinyin A total of four categories:

Chinesehelper.java Chinese Simplified and traditional conversion class
Pinyinformat.java Pinyin Format Class
Pinyinhelper.java Kanji to Pinyin class
Pinyinresource.java Resource file Load class

II. introduction of the main methods

A converttopinyinstring (string str, string separator) * Converts a string into a phonetic alphabet in the appropriate format

 Public Static string converttopinyinstring (String str, string separator)  Public Static String converttopinyinstring (String str, string separator, Pinyinformat Pinyinformat)

Results:

String words ="Gas Money"; Final String separator =" ";//héqìshēng cái (default format)pinyinhelper.converttopinyinstring (words, separator); Pinyinhelper.converttopinyinstring (str,",", Pinyinformat.with_tone_mark);//Nǐ,hǎo,shì,jiè//with TonesPinyinhelper.converttopinyinstring (str,",", Pinyinformat.with_tone_number);//ni3,hao3,shi4,jie4//a tone with a numberPinyinhelper.converttopinyinstring (str,",", Pinyinformat.without_tone);//Ni,hao,shi,jie

Getshortpinyin (String str) Chinese string---First letter Str

 Public Static  " Hello World "//

Three Converttopinyinarray (char c) Single character string---Pinyin converts a single Chinese character to the phonetic alphabet of the corresponding format

 Public Static String[] Converttopinyinarray (char  c)publicstatic string[] Converttopinyinarray (char" gas money "//  Héhèhuóhuòhú = Pinyinhelper.converttopinyinarray (Words.tochararray () [0]); 

Four Hasmultipinyin (char c) determines whether a Chinese character is polyphone true for Polyphone, otherwise returns false

 Public static Boolean hasmultipinyin (char  c)//  falseprintln ( Pinyinhelper.hasmultipinyin (' li '));


Android--jpinyin class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.