package ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import .;
import .;
import .;
import .;
import .;
import .;
import .;
public class PinyinUtils {
private static final Logger logger = ("devLog");
public static Map<String,String> dictionary = new HashMap<String,String>();
static{
BufferedReader br = null;
try {
File file = new File("./config/duoyinzi_pinyin.txt");
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
String line = null;
while((line=())!=null){
String[] arr = ("#");
if((arr[1])){
String[] sems = arr[1].split(" ");
for (String sem : sems) {
if((sem)){
(sem , arr[0]);
}
}
}
}
} catch (UnsupportedEncodingException e) {
();
} catch (FileNotFoundException e) {
();
} catch (IOException e) {
();
}finally{
if(br!=null){
try {
();
} catch (IOException e) {
();
}
}
}
}
public static String[] chineseToPinYin(char chineseCharacter) throws BadHanyuPinyinOutputFormatCombination{
HanyuPinyinOutputFormat outputFormat = new HanyuPinyinOutputFormat();
(HanyuPinyinToneType.WITHOUT_TONE);
();
(HanyuPinyinVCharType.WITH_V);
if(chineseCharacter>=32 && chineseCharacter<=125){
return new String[]{(chineseCharacter)};
}
return (chineseCharacter, outputFormat);
}
public static String chineseToPinYinF(String chineseCharacter) throws BadHanyuPinyinOutputFormatCombination{
if((chineseCharacter)){
return null;
}
char[] chs = ();
StringBuilder result = new StringBuilder();
for(int i=0;i<;i++){
String[] arr = chineseToPinYin(chs[i]);
if(arr==null){
("");
}else if(==1){
(arr[0]);
}else if(arr[0].equals(arr[1])){
(arr[0]);
}else{
String prim = (i, i+1);
String lst = null,rst = null;
if(i<=()-2){
rst = (i,i+2);
}
if(i>=1 && i+1<=()){
lst = (i-1,i+1);
}
String answer = null;
for (String py : arr) {
if((py)){
continue;
}
if((lst!=null && ((lst))) ||
(rst!=null && ((rst)))){
answer = py;
break;
}
if(((prim))){
answer = py;
}
}
if(answer!=null){
(answer);
}else{
("no answer ch="+chs[i]);
}
}
}
return ().toLowerCase();
}
public static String chineseToPinYinS(String chineseCharacter) throws BadHanyuPinyinOutputFormatCombination{
if((chineseCharacter)){
return null;
}
char[] chs = ();
StringBuilder result = new StringBuilder();
for(int i=0;i<;i++){
String[] arr = chineseToPinYin(chs[i]);
if(arr==null){
("");
}else if(==1){
(arr[0].charAt(0));
}else if(arr[0].equals(arr[1])){
(arr[0].charAt(0));
}else{
String prim = (i, i+1);
String lst = null,rst = null;
if(i<=()-2){
rst = (i,i+2);
}
if(i>=1 && i+1<=()){
lst = (i-1,i+1);
}
String answer = null;
for (String py : arr) {
if((py)){
continue;
}
if((lst!=null && ((lst))) ||
(rst!=null && ((rst)))){
answer = py;
break;
}
if(((prim))){
answer = py;
}
}
if(answer!=null){
((0));
}else{
("no answer ch="+chs[i]);
}
}
}
return ().toLowerCase();
}
}