The domain name of the enterprise mailbox is generally [email protected] Company domain name, or [email protected] Company domain name this form. Here I only list [email protected] Company domain name this form.
The company wants me to do a business mailbox fuzzy matching and verification, just received thought difficult. Results online, found similar API. Instant little case.
Introducing JAR Package: Pinyin4j-2.5.0.jar
The code is my own casually write, should also be able to optimize, with two cycles, because we man contains a lot of polyphone.
/**
* Single Man Check
* @param Chinese
* @return
*/
public static Boolean Checkspell (String chinese,string mailaccount) {
Boolean result = false;
try {
Set conversion format
Hanyupinyinoutputformat DefaultFormat = new Hanyupinyinoutputformat ();
Defaultformat.setcasetype (hanyupinyincasetype.lowercase); Setting case
Defaultformat.settonetype (Hanyupinyintonetype.without_tone); Set up a non-tonal representation
char[] arr = Chinese.tochararray ();
for (int j = 0; J < Arr.length; J + +) {
result = false;
Calling the Ruby API
string[] Pinyin = Pinyinhelper.tohanyupinyinstringarray (Arr[j], defaultformat);
for (int i = 0; i < pinyin.length; i++) {
Eligible to jump out of the loop directly
if (Mailaccount.startswith (Pinyin[i])) {
Mailaccount = mailaccount.substring (Mailaccount.indexof (Pinyin[i]) +pinyin[i].length ());
result = true;
Break
}
}
if (result = = True) {
Continue
}
return result;
}
} catch (Badhanyupinyinoutputformatcombination e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
return result;
}
public static void Main (string[] args) {
Boolean result = Checkspell ("Changxing thin", "[email protected]");
SYSTEM.OUT.PRINTLN (result);
result = Checkspell ("Changxing thin", "[email protected]");
SYSTEM.OUT.PRINTLN (result);
result = Checkspell ("Changxing thin", "[email protected]");
SYSTEM.OUT.PRINTLN (result);
result = Checkspell ("Changxing thin", "[email protected]");
SYSTEM.OUT.PRINTLN (result);
result = Checkspell ("Changxing thin", "[email protected]");
}
Copyright, reproduced please specify the source.
About the mailbox how to verify is not the real business mailbox (Java Kanji and English call)