private boolean verifyPushBack(int current, int next) { int shortenedSyllable = next - current - 1; verifyText.setText(text.getText(), text.getStart() + current, shortenedSyllable); verify.setText(verifyText); if (verify.next() != shortenedSyllable || verify.getRuleStatus() == 0) return false; verifyText.setText(text.getText(), text.getStart() + next - 1, text.getLength() - next + 1); verify.setText(verifyText); return (verify.next() != BreakIterator.DONE && verify.getRuleStatus() != 0); }
@Override public Lexem lexer_next() { end = iterator.next(); if (end == BreakIterator.DONE) return null; if (start >= end) return null; int lexemId = iterator.getRuleStatus(); Lexem lexem = new Lexem(lexemId, text.substring(start, end), start, end); // System.out.println(lexem.toString()); start = end; // Prepare for the next iteration return lexem; }
@Override public int next() { int current = current(); int next = rules.next(); if (next == BreakIterator.DONE) return next; else next += workingOffset; char c = working.current(); int following = rules.next(); // lookahead if (following != BreakIterator.DONE) { following += workingOffset; if (rules.getRuleStatus() == 0 && laoSet.contains(c) && verifyPushBack(current, next)) { workingOffset = next - 1; working.setText( text.getText(), text.getStart() + workingOffset, text.getLength() - workingOffset); return next - 1; } rules.previous(); // undo the lookahead } return next; }