Class ScannerSrxTextIterator
- All Implemented Interfaces:
Iterator<String>, TextIterator
Quick and Dirty implementation of TextIterator using Scanner.
Preliminary tests showed that it requires between 50% and 100% more time to complete than default text iterator. Probably the reason is slow matching of exception rules, but also splitting break-rule-only is slower.
This implementation is also not able to solve overlapping rules, like other one-big-pattern-scan iterators and there seems to be no easy solution. Although this should not happen in input patterns, in large SRX file using cascading it is very easy to miss this.
One solution could be sorting patterns by length, but this is sometimes
impossible to do. For example:
Rules are "(ab)+" and "a(b)+"
Inputs are "ababx" and "abbbx"
For first input order of exception rules should be reversed for the text
to be split as early as possible, but for the second input it shouldn't.
The solution could be to use reluctant quantifiers instead of greedy ones,
but that is changing the input patterns provided by user and therefore
is undesirable.
- Author:
- loomchild
-
Constructor Summary
ConstructorsConstructorDescriptionScannerSrxTextIterator(SrxDocument document, String languageCode, Reader reader, Map<String, Object> parameterMap) ScannerSrxTextIterator(SrxDocument document, String languageCode, String text, Map<String, Object> parameterMap) -
Method Summary
Methods inherited from class AbstractTextIterator
remove, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining
-
Constructor Details
-
ScannerSrxTextIterator
-
ScannerSrxTextIterator
-
-
Method Details
-
hasNext
public boolean hasNext()- Returns:
- true if there are more segments
-
next
- Returns:
- next segment in text, or null if end of text has been reached.
-