Beispiel #1
0
  public void testCompare(String documentName, SrxParser[] parsers) {
    SrxDocument previousDocument = null;
    for (SrxParser parser : parsers) {
      Reader reader = getReader(getResourceStream(documentName));
      SrxDocument document = parser.parse(reader);

      if (previousDocument != null) {
        assertSrxDocumentEquals(previousDocument, document);
      }

      previousDocument = document;
    }
  }
Beispiel #2
0
  private void testSrx2Ticket1(SrxParser parser) {
    Reader reader = getReader(getResourceStream(TICKET_1_DOCUMENT_NAME));

    SrxDocument document = parser.parse(reader);

    assertTrue(document.getCascade());

    List<LanguageRule> languageRuleList = document.getLanguageRuleList("en");

    LanguageRule languageRule = languageRuleList.get(0);
    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());
  }
Beispiel #3
0
  private void testSrx1(SrxParser parser) {
    Reader reader = getReader(getResourceStream(SRX_1_DOCUMENT_NAME));

    SrxDocument document = parser.parse(reader);

    assertFalse(document.getCascade());

    List<LanguageRule> languageRuleList = document.getLanguageRuleList("en");
    assertEquals(1, languageRuleList.size());

    LanguageRule languageRule = languageRuleList.get(0);
    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());
  }
Beispiel #4
0
  private void testSrx2(SrxParser parser) {
    Reader reader = getReader(getResourceStream(SRX_2_DOCUMENT_NAME));

    SrxDocument document = parser.parse(reader);

    assertTrue(document.getCascade());

    List<LanguageRule> languageRuleList = document.getLanguageRuleList("fr_FR");
    assertEquals(2, languageRuleList.size());

    LanguageRule languageRule = languageRuleList.get(0);
    assertEquals("French", languageRule.getName());

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

    Rule rule0 = ruleList.get(0);
    assertEquals(" [Mm]lle\\.", rule0.getBeforePattern());
    assertEquals("\\s", rule0.getAfterPattern());

    Rule rule1 = ruleList.get(1);
    assertEquals("\\s[Mm]lles\\.", rule1.getBeforePattern());
    assertEquals("\\s", rule1.getAfterPattern());
  }
Beispiel #5
0
 private void testSrx2Invalid(SrxParser parser) {
   Reader reader = getReader(getResourceStream(INVALID_DOCUMENT_NAME));
   parser.parse(reader);
 }