Package net.sourceforge.segment.srx

Examples of net.sourceforge.segment.srx.Rule


          after = r.getAfterbreak().getContent();
        } else {
          after = "";
        }

        Rule rule = new Rule(breakRule, before, after);
        languageRule.addRule(rule);
      }
      languageRuleMap.put(languageRule.getName(), languageRule);
    }
View Full Code Here


   */
  private List<List<Rule>> groupRules(List<Rule> ruleList) {
    List<List<Rule>> ruleGroupList = new ArrayList<List<Rule>>();

    List<Rule> ruleGroup = null;
    Rule previousRule = null;
   
    for (Rule rule : ruleList) {
      if (previousRule == null ||
          rule.isBreak() != previousRule.isBreak()) {
        ruleGroup = new ArrayList<Rule>();
        ruleGroupList.add(ruleGroup);
      }
      ruleGroup.add(rule);
      previousRule = rule;
View Full Code Here

  private LanguageRule generateLanguageRule(int ruleCount, int ruleLenght) {
    LanguageRule languageRule = new LanguageRule("");
    // Add rules
    for (int i = 0; i < ruleCount; ++i) {
      Rule rule = generateRule(ruleLenght);
      languageRule.addRule(rule);
    }
    // Add end of sentence rule
    languageRule.addRule(new Rule(true, "\\.", " "));
    return languageRule;
  }
View Full Code Here

      if (i != length - 1) {
        regex.append('|');
      }
    }
    regex.append(')');
    Rule rule = new Rule(false, regex + "\\.", " ");
    return rule;
  }
View Full Code Here

      assertEquals("Default", languageRule.getName());

      List<Rule> ruleList = languageRule.getRuleList();
      assertEquals(1, ruleList.size());   

      Rule rule = ruleList.get(0);
      assertEquals("[\\.!?…]['»\"”\\)\\]\\}]?\\u0002?\\s", rule.getBeforePattern());
      assertEquals("", rule.getAfterPattern());
  }
View Full Code Here

    assertEquals("Default", languageRule.getName());

    List<Rule> ruleList = languageRule.getRuleList();
    assertEquals(5, ruleList.size());

    Rule rule = ruleList.get(1);
    assertEquals("[Ee][Tt][Cc]\\.", rule.getBeforePattern());
    assertEquals("\\s[a-z]", rule.getAfterPattern());
  }
View Full Code Here

    assertEquals("French", languageRule.getName());

    List<Rule> ruleList = languageRule.getRuleList();
    assertEquals(4, ruleList.size());

    Rule rule = ruleList.get(1);
    assertEquals("\\s[Mm]lles\\.", rule.getBeforePattern());
    assertEquals("\\s", rule.getAfterPattern());
  }
View Full Code Here

TOP

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

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.