Collection<AnnotationFS> results = new HashSet<AnnotationFS>();
stream.moveToFirst();
FSIterator<AnnotationFS> streamPointer = stream.copy();
while (stream.isValid()) {
RutaBasic anchorBasic = (RutaBasic) stream.get();
streamPointer.moveTo(anchorBasic);
List<RutaBasic> basicsToAdd = new ArrayList<RutaBasic>();
basicsToAdd.add(anchorBasic);
String text = anchorBasic.getCoveredText();
StringBuilder candidate = new StringBuilder(text);
String lastCandidate = candidate.toString();
if (text.length() != 1 || !ignoreToken.contains(text)) {
List<AnnotationFS> interResults = new ArrayList<AnnotationFS>();
while (streamPointer.isValid()) {
boolean skip = false;
String currentBasicText = basicsToAdd.get(basicsToAdd.size()-1).getCoveredText();
if (currentBasicText.length() == 1 && ignoreToken.contains(currentBasicText)) {
skip = true;
}
List<String> types = null;
if (!skip) {
types = containsFragment(candidate.toString(), ignoreCase, ignoreLength, edit,
distance, ignoreToken);
}
if (skip || types != null) {
streamPointer.moveToNext();
if (streamPointer.isValid()) {
RutaBasic next = (RutaBasic) streamPointer.get();
// List<String> contains = contains(candidate,
// ignoreCase,
// ignoreLength, edit, distance, ignoreToken);
if (!skip) {
tryToCreateAnnotation(types, stream, results, basicsToAdd, candidate.toString(),
interResults, ignoreCase, ignoreLength, edit, distance, ignoreToken,
typeMap);
}
lastCandidate = candidate.toString();
candidate.append(next.getCoveredText());
basicsToAdd.add(next);
} else {
// !streamPointer.isValid();
tryToCreateAnnotation(types, stream, results, basicsToAdd, lastCandidate,