Class ScannerSrxTextIterator

java.lang.Object
net.loomchild.segment.AbstractTextIterator
net.loomchild.segment.srx.legacy.ScannerSrxTextIterator
All Implemented Interfaces:
Iterator<String>, TextIterator

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.

Author:
loomchild
  • Constructor Details

  • Method Details

    • hasNext

      public boolean hasNext()
      Returns:
      true if there are more segments
    • next

      public String next()
      Returns:
      next segment in text, or null if end of text has been reached.