Importjava.util.ArrayList;ImportJava.util.HashMap;Importjava.util.List;ImportJava.util.Map; Public classZhybtest { Public Static voidMain (string[] args) {Map<String,Object> map=NewHashmap<string, object>(); Map.put ("A0", "?"); Map.put ("A1", "?"); Map.put ("A2", "?"); Map.put ("A3", "Æ"); Map.put ("A4", "?"); Map.put ("A5", "?"); Map.put ("A6", "?"); Map.put ("A7", "?"); Map.put ("A8", "?"); Map.put ("A9", "D"); Map.put ("A10", "?"); Map.put ("A11", "?"); Map.put ("A12", "?"); String Str= "☆bassinet [, Bæs? ') NET] n. Cradle Cradle can also be called Cradle [' kre?d (?) L]. but! Cradle The word also has another meaning, we look at the example sentence: Ah! Yellow river! The cradle of Chinese nation! Yes, it is the birthplace of the meaning ~ "; String txt=STR;//Give the STR string to txt firstList list_false=NewArrayList ();//only the non-rotating phonetic transcription is storedList list_true=NewArrayList ();//only the phonetic transcription that has been transferred while(Str.indexof ("[") >0&&str.indexof ("]") >0) {String str_a=str.substring (Str.indexof ("[") +1, Str.indexof ("]")); //System.out.println ("Pre-conversion---------->" +str_a);List_false.add (str_a); for(intI=0;i<map.size (); i++){ //First, find out if the string has special characters in the map. if(Str_a.indexof (Map.get ("a" +i). ToString ()) >0){ //Here's the key that transforms the special character into a map if(Map.get ("a" +i). ToString (). Equals (Str_a.substring (Str_a.indexof (Map.get ("a" +i). ToString ()), Str_a.indexof ( Map.get ("A" +i). ToString ()) +1))){ //System.out.println (Map.get ("a" +i) + "switch to--->" + "a" +i);Str_a=str_a.replace (Map.get ("a" +i). ToString (), "a" +i); //System.out.println ("converted results---------->" +str_a); } } } //System.out.println ("converted---------->" +str_a);List_true.add (str_a);//Save to list after each conversionStr=str.substring (Str.indexof ("]") +1, Str.length ()); } for(intI=0;i<list_false.size (); i++) {txt=Txt.replace (List_false.get (i). ToString (), List_true.get (i). ToString ()); } System.out.println ("Print out ———————— >" +txt); }}
Hope to help everyone, we remember to leave a comment ~ o (∩_∩) o
JAVA, SQL Server does not support English phonetic transcription, for the [] phonetic transcription of the replacement