public String[] getSentences(){ ArrayList<String> set=new ArrayList<String>(); int length=input.getText().length(); for(int i=0,last=0;i<length;i++){ String s=String.valueOf(input.getText().charAt(i)); if(s.equals("\n")) last=i+1; if(s.equals(".")||s.equals(",")||s.equals("。")||s.equals("。")||s.equals("!")||s.equals("?")||s.equals("?")||s.equals("!")||s.equals(",")){ set.add(input.getText().substring(last,i)+s); last=i+1; } } return set.<String>toArray(new String[set.size()]); } public String getKeySentences(String[] key,String[] sentences){ String result=""; A: for(int i=0;i<sentences.length;i++){ for (int k = 0; k < key.length; k++) if (sentences[i].contains(key[k].subSequence(0, key[k].length()))) { result += sentences[i] + "\n"; continue A; } } return result; }
添加回答
举报
0/150
提交
取消