1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| private void addEachForward(BreakIterator boundary, String source, int pos) {
int start = boundary.first(),posBegin= 0,posEnd=0,posBeginWord=0,posEndWord=0;
String word = null,tmp = null;
StringTokenizer st;
String delim = "?.,;':- ()[]_=+*/!\\\"%¡";
for (int end = boundary.next();end != BreakIterator.DONE;start = end, end = boundary.next())
{
word =source.substring(start,end);
posEnd = pos+boundary.current() ;
posBegin = posEnd-word.length() ;
if(!word.equals("null"))
{
st = new StringTokenizer(word,delim);
while(st.hasMoreTokens())
{
tmp = st.nextToken().trim();
if(tmp.length()!=0)//&& !tmp.equals("?"))//delim.indexOf(tmp)==-1)
{
posBeginWord=posBegin+word.indexOf(tmp);
posEndWord= posBeginWord+tmp.length() ;
System.out.println(tmp);
copeWithWordByBreak(tmp, new OffsetPair(posBeginWord,posEndWord));
}
}
}
}
} |
Partager