Package net.sourceforge.segment.srx

Examples of net.sourceforge.segment.srx.RuleMatcher


    this.endPosition = 0;

    this.ruleMatcherList = new LinkedList<RuleMatcher>();
    for (LanguageRule languageRule : languageRuleList) {
      for (Rule rule : languageRule.getRuleList()) {
        RuleMatcher matcher = new RuleMatcher(document, rule, text);
        ruleMatcherList.add(matcher);
      }
    }

  }
View Full Code Here


      if (segment == null) {
        initMatchers();
      }
      boolean found = false;
      while ((ruleMatcherList.size() > 0) && !found) {
        RuleMatcher minMatcher = getMinMatcher();
        endPosition = minMatcher.getBreakPosition();
        if (minMatcher.getRule().isBreak() &&
            endPosition > startPosition) {
          found = true;
          cutMatchers();
        }
        moveMatchers();
View Full Code Here

    return (startPosition < text.length());
  }
 
  private void initMatchers() {
    for (Iterator<RuleMatcher> i = ruleMatcherList.iterator(); i.hasNext();) {
      RuleMatcher matcher = i.next();
      matcher.find();
      if (matcher.hitEnd()) {
        i.remove();
      }
    }
  }
View Full Code Here

  /**
   * Przesuwa iteratory na kolejną pozycje jeśli to konieczne.
   */
  private void moveMatchers() {
    for (Iterator<RuleMatcher> i = ruleMatcherList.iterator(); i.hasNext();) {
      RuleMatcher matcher = i.next();
      while (matcher.getBreakPosition() <= endPosition) {
        matcher.find();
        if (matcher.hitEnd()) {
          i.remove();
          break;
        }
      }
    }
View Full Code Here

  /**
   * Move matchers that start before previous segment end.
   */
  private void cutMatchers() {
    for (Iterator<RuleMatcher> i = ruleMatcherList.iterator(); i.hasNext();) {
      RuleMatcher matcher = i.next();
      if (matcher.getStartPosition() < endPosition) {
        matcher.find(endPosition);
        if (matcher.hitEnd()) {
          i.remove();
        }
      }
    }
  }
View Full Code Here

  /**
   * @return Zwraca iterator pierwszego trafionego dopasowania
   */
  private RuleMatcher getMinMatcher() {
    int minPosition = Integer.MAX_VALUE;
    RuleMatcher minMatcher = null;
    for (RuleMatcher matcher : ruleMatcherList) {
      if (matcher.getBreakPosition() < minPosition) {
        minPosition = matcher.getBreakPosition();
        minMatcher = matcher;
      }
View Full Code Here

TOP

Related Classes of net.sourceforge.segment.srx.RuleMatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.