1.Processing Text 處理字串
Input: original text 原始字串
Output: edited text 編輯後字串
// neMAp = <span content, span id>
private HashMap neMap = new HashMap();
// neLength = span content length
private ArrayList neLength = new ArrayList();
// get <span> id and content
// replace <span>content</span> to <util>content
// 取得<span>的id和所包的文字內容
// 將<span>文字內容</span>換成<util>content
private String parseContent(String text) {
String[] contArray = text.split("<span id=\"");
ArrayList keyArray = new ArrayList();
for (String ca : contArray) {
String span = ca.split("</span>")[0];
keyArray.add(span);
}
for(int i = 1 ; i < keyArray.size() ; i++){
String[] temp = keyArray.get(i).split("\">");
neMap.put(temp[1], temp[0]);
neLength.add(temp[1].length());
text = text.replace("<span id=\""+temp[0]+"\">"+temp[1]+"</span>", "<util>"+temp[1]);
}
return text;
}