I have `a string example = "this site holds all the examples from The Java Developers Almanac and more. Copy and paste these examples directly into your applications"
after token and do some i want on string example i have arraylist like :
ArrayList <token > arl = " "this site holds ", "holds all the examples ", "the examples from The Java Developers", " Copy and paste " )
"this site holds ", i know position start and end in string test : star = 1 end = 3 " holds all the examples ", i know position stat = 3 end = 6, "the examples from The Java Developers", i know position stat = 5 end =10, "Copy and paste" i know position stat = 14 end = 17,
we can see,some element in arl overlaping :"this site holds ","holds all the examples ","the examples from The Java Developers".
The problem here is how can i merge overlaping element to recived arraylist like
ArrayList result ="" this site holds all the examples from The Java Developers","" Copy and paste"";
Here my code : but it only merge fist elecment if check is element overloaping
public ArrayList<TextChunks> finalTextChunks(ArrayList<TextChunks> textchunkswithkeyword) {
ArrayList<TextChunks > result = (ArrayList<TextChunks>) textchunkswithkeyword.clone();
//System.out.print(result.size());
int j;
for(int i=0;i< result.size() ;i++) {
int index = i;
if(i+1>=result.size()){
break;
}
j=i+1;
if(result.get(i).checkOverlapingTwoTextchunks(result.get(j))== true) {
TextChunks temp = new TextChunks();
temp = handleOverlaping(textchunkswithkeyword.get(i),textchunkswithkeyword.get(j),resultSearchEngine);
result.set(i, temp);
result.remove(j);
i = index;
continue;
}
}
return result;
}
}
Thanks in avadce