日期:2014-05-20 浏览次数:20671 次
public static void simplySentenceOfAllDocument(ArrayList<String> SentenceOfAllDocument,ArrayList<String> ConceptFromExcel){
ArrayList<Integer> IndexOfSentenceOfAllDocument=new ArrayList();
System.out.println("countofWordInSentence:初始句子共有 "+SentenceOfAllDocument.size()+"个");
for(int i=0;i<ConceptFromExcel.size();i++){
System.out.println(i+"/"+ConceptFromExcel.size());
for(int m=0;m<SentenceOfAllDocument.size();m++){
if(!SentenceOfAllDocument.get(m).contains(ConceptFromExcel.get(i))){
//如果句子里面不存在这个词,则将句子的索引放入数组
IndexOfSentenceOfAllDocument.add(m);
}else{
//句子里面有这个词,则查找这个句子的索引是否在数组中,如果存在,则删除这个索引
for(int j=0;j<IndexOfSentenceOfAllDocument.size();j++){
if(m==IndexOfSentenceOfAllDocument.get(j)){
IndexOfSentenceOfAllDocument.remove(j);
}
}
}
}
}
for(int n=0;n<IndexOfSentenceOfAllDocument.size();n++){
SentenceOfAllDocument.remove(IndexOfSentenceOfAllDocument.get(n));
}
System.out.println("countofWordInSentence:精简后句子共有 "+SentenceOfAllDocument.size()+"个");
}
for(int i=SentenceOfAllDocument.size-1;i>=0;i--){
int count=0;
for(String str:ConceptFromExcel){
if(!SentenceOfAllDocument.getIndex(i).equals(str)){
count++;
}else{
break;
}
}
if(count==ConceptFromExcel.size()){
SentenceOfAllDocument.remove(SentenceOfAllDocument.getIndex(i));}
)
}
System.out.println(SentenceOfAllDocument);