public class ScannerSrxTextIterator extends AbstractTextIterator
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.
| Constructor and Description |
|---|
ScannerSrxTextIterator(SrxDocument document,
String languageCode,
Reader reader,
Map<String,Object> parameterMap) |
ScannerSrxTextIterator(SrxDocument document,
String languageCode,
String text,
Map<String,Object> parameterMap) |
public ScannerSrxTextIterator(SrxDocument document, String languageCode, String text, Map<String,Object> parameterMap)
public boolean hasNext()
public String next()
Copyright © 2015. All Rights Reserved.