code: public void buildIntervals(SAXRecords records, double[] originalTimeSeries,
        int slidingWindowSize) {
  
      records.buildIndex();
  
      for (int ruleIdx = 1; ruleIdx <= this.theRules.size(); ruleIdx++) {
  
        RePairRule rr = this.theRules.get(ruleIdx);
  
        String[] split = rr.expandedRuleString.split(" ");
        for (int strPos : rr.getOccurrences()) {
          Integer tsPos = records.mapStringIndexToTSPosition(strPos + split.length - 1);
          if (null == tsPos) {
            rr.ruleIntervals.add(new RuleInterval(records.mapStringIndexToTSPosition(strPos),
                originalTimeSeries.length + 1)); // +1 cause right point is excluded
          }
          else {
            rr.ruleIntervals.add(new RuleInterval(records.mapStringIndexToTSPosition(strPos),
                records.mapStringIndexToTSPosition(strPos + split.length - 1) + slidingWindowSize));
          }
        }
      }
  
    }
docs: Builds a table of intervals corresponding to the grammar rules.
  
  @param records the records to build intervals for.
  @param originalTimeSeries the timeseries.
  @param slidingWindowSize the sliding window size.