beforeWidth = allowableWidth / 3;
afterWidth = (2 * allowableWidth) / 3;
}*/
//StringSource ss = new StringSource(files, false);
TokenSequenceSource ts = new TokenSequenceSource(files);
boolean doSort = true;
for(TokenSequence t : ts) {
//s = s.replaceAll("\\s+", " ");
//Tokeniser t = new Tokeniser(null);
//t.tokenise(s);
int sstart = t.getOffset();
int send = t.getSourceString().length() + sstart;
for(Token token : t.getTokens()) {
if(token.getValue().equalsIgnoreCase(word)) {
int wstart = token.getStart();
int wend = token.getEnd();
String before = t.getStringAtOffsets(Math.max(sstart, wstart-beforeWidth), wstart);
before = before.replaceAll("\\s+", " ");
if(before.startsWith(" ")) before = "." + before.substring(1);
if(before.length() < beforeWidth) {
before = StringTools.multiplyString(".", beforeWidth - before.length()) + before;
}
//if(wstart < beforeWidth) {
// before = StringTools.multiplyString(" ", beforeWidth - wstart) + t.getStringAtOffsets(0, wstart);
//} else {
// before = t.getStringAtOffsets(wstart - beforeWidth, wstart);
//}
String after = t.getStringAtOffsets(wend, Math.min(send, wend + afterWidth));
after = after.replaceAll("\\s+", " ");
//if(s.length() - wend > afterWidth) {
// after = s.substring(wend, wend + afterWidth);
//} else {
// after = s.substring(wend);
//}
String display = before + " " + token.getValue() + " " + after;
String sort = "";
if("interleave".equals(mode)) {
sort = interleave(before, after, true);
} else if("left".equals(mode)) {
StringBuffer sb = new StringBuffer(before.toLowerCase());
sb.reverse();
sort = sb + "\n" + after.toLowerCase();
} else if("right".equals(mode)) {
sort = after.toLowerCase() + "\n" + before.toLowerCase();
} else {
doSort = false;
}
ConcordanceEntry entry = new ConcordanceEntry();
entry.text = display;
entry.start = token.getStartXPoint();
entry.end = token.getEndXPoint();
entry.file = ts.getCurrentFile().getAbsolutePath();
concordance.put(entry, sort);
}
}
}
if(!doSort) {