我的一句話就是"ram is going to school"
給輸入它會給一個解析樹後:使用HashMap的重新排序的字符串值
2|TYPE| nx0-VPadjn-VPx1 0|NOUN| NXN 1|AUX| Vvx 3|PREP| Pnx 4|NOUN| NXN
我想將它重新排序,以
0|NOUN| NXN 1|AUX| Vvx 2|TYPE| nx0-VPadjn-VPx1 3|PREP| Pnx 4|NOUN| NXN
我寫了這個代碼。我應該怎麼做才能使它工作?
請告訴我,HashMap
是否可能。如果可能的話請告訴我如何?
for(int j=1;j<2;j++) //when multiple parsing is to be done then change the limit to ---parsedderived.length
{
parsedderived[j] = parsedderived[j].replaceAll("\\^|\\(|\\)|\\~|\\.|\"", " ");
parsedderived[j] = parsedderived[j].replaceAll("\\{\\S+\\}", "");
parsedderived[j] = parsedderived[j].replaceAll("[ ]+", " ");
parsedderived[j] = parsedderived[j].replaceAll("(\\d+)\\s+(\\S+)\\s+(\\S+)", "[email protected]@$3");
preparedStatement.setString(4, parsedderived[j]);
//String[] x=objSentenceStatusImpl.getStrSourceSen().split("");
String[] derivedsen=parsedderived[j].split(" ");
// for(int k=1;k<derivedsen.length;k++)
// {
// String[] derivedsen1=derivedsen[k].split("");
// System.out.println(derivedsen);
// }
String[]Senwords=objSentenceStatusImpl.getStrSourceSen().split("\\s+");//original sentence ram is going to school
Map<Integer, String> entriesMap = new LinkedHashMap<Integer, String>();
for(int i = 0; i < Senwords.length; i++) {//for iterration of sen
parsedderived[j]=parsedderived[j].replaceFirst(" ","");
parsedderived[j]=parsedderived[j].replaceAll(" ", "##");
System.out.println(parsedderived[j]);
}
}
您想要維護的任何特定訂單? – NINCOMPOOP 2013-04-28 15:32:56
@Noob UnChained我想根據索引值0,1,2,3進行排序,該索引值在'|'開頭 – user2319395 2013-04-29 05:59:32
該字符串中是否有空格? – NINCOMPOOP 2013-04-29 06:01:51