Package org.languagetool.rules.patterns

Examples of org.languagetool.rules.patterns.Element


  }

  public void testApostropheElement() throws Exception {
    createIndex("Daily Bleed's Anarchist Encyclopedia");
    final List<Element> elements1 = Arrays.asList(
            new Element("Bleed", false, false, false),
            new Element("'", false, false, false),
            new Element("s", false, false, false)
    );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements1, "desc", "msg", "shortMsg");

    final List<Element> elements2 = Arrays.asList(
            new Element("Bleed", false, false, false),
            new Element("'", false, false, false),
            new Element("x", false, false, false)
    );
    final PatternRule rule2 = new PatternRule("RULE", new English(), elements2, "desc", "msg", "shortMsg");

    final SearcherResult searcherResult1 = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
    assertEquals(1, searcherResult1.getMatchingSentences().size());
View Full Code Here


    assertEquals(0, searcherResult2.getMatchingSentences().size());
  }

  public void testWithException() throws Exception {
    createIndex("How to move back and fourth from linux to xmb?");
    final Element exceptionElem = new Element("forth|back", false, true, false);
    exceptionElem.setStringPosException("exception", false, false, false, false, false, "POS", false, false);
    final List<Element> elements = Arrays.asList(
            new Element("move", false, false, false),
            exceptionElem
    );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final Searcher errorSearcher = new Searcher(directory);
    final SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
View Full Code Here

    assertEquals("RULE1", rule.getId());
  }

  public void testNegatedMatchAtSentenceStart() throws Exception {
    createIndex("How to move?");
    final Element negatedElement = new Element("Negated", false, false, false);
    negatedElement.setNegation(true);
    final List<Element> elements = Arrays.asList(
            negatedElement,
            new Element("How", false, false, false)
    );
    final Searcher errorSearcher = new Searcher(directory);
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
    assertEquals(1, searcherResult.getCheckedSentences());
View Full Code Here

    assertEquals("RULE1", rule.getId());
  }

  public void testWithOneElementWithException() throws Exception {
    createIndex("How to move back and fourth from linux to xmb?");
    final Element exceptionElem = new Element("", false, true, false);
    exceptionElem.setStringPosException("exception", false, false, false, false, false, "POS", false, false);
    final List<Element> elements = Arrays.asList(
            exceptionElem
    );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final Searcher errorSearcher = new Searcher(directory);
View Full Code Here

  private final Language language;

  public MissingVerbRule(ResourceBundle messages, German language) {
    this.language = language;
    rule1 = new PatternRule("internal", language, Arrays.asList(
            new Element("Vielen", true, false, false),
            new Element("Dank", true, false, false)), "", "", "");
    rule2 = new PatternRule("internal", language, Arrays.asList(
            new Element("Herzlichen", true, false, false),
            new Element("Glückwunsch", true, false, false)), "", "", "");
    if (messages != null) {
      super.setCategory(new Category(messages.getString("category_grammar")));
    }
    setDefaultOff();
    addExamplePair(Example.wrong("<marker>In diesem Satz kein Wort.</marker>"),
View Full Code Here

            "</matches>\n"));
  }

  private class FakeRule extends PatternRule {
    public FakeRule() {
      super("FAKE_ID", TestTools.getDemoLanguage(), Collections.singletonList(new Element("foo", true, false, false)),
              "My fake description", "Fake message", "Fake short message");
    }
View Full Code Here

  }

  public void testWithNewRule() throws Exception {
    createIndex("How to move back and fourth from linux to xmb?");
    final List<Element> elements = Arrays.asList(
        new Element("move", false, false, false),
        new Element("back", false, false, false)
        );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final Searcher errorSearcher = new Searcher(directory);
    final SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
    assertEquals(1, searcherResult.getCheckedSentences());
View Full Code Here

  }

  public void testWithRegexRule() throws Exception {
    createIndex("How to move back and fourth from linux to xmb?");
    final List<Element> elements = Arrays.asList(
        new Element("move", false, false, false),
        new Element("forth|back", false, true, false)
        );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final Searcher errorSearcher = new Searcher(directory);
    final SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
    assertEquals(1, searcherResult.getCheckedSentences());
View Full Code Here

  }

  public void testApostropheElement() throws Exception {
    createIndex("Daily Bleed's Anarchist Encyclopedia");
    final List<Element> elements1 = Arrays.asList(
        new Element("Bleed", false, false, false),
        new Element("'", false, false, false),
        new Element("s", false, false, false)
        );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements1, "desc", "msg", "shortMsg");

    final List<Element> elements2 = Arrays.asList(
        new Element("Bleed", false, false, false),
        new Element("'", false, false, false),
        new Element("x", false, false, false)
        );
    final PatternRule rule2 = new PatternRule("RULE", new English(), elements2, "desc", "msg", "shortMsg");

    final SearcherResult searcherResult1 = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
    assertEquals(1, searcherResult1.getMatchingSentences().size());
View Full Code Here

    assertEquals(0, searcherResult2.getMatchingSentences().size());
  }

  public void testWithException() throws Exception {
    createIndex("How to move back and fourth from linux to xmb?");
    final Element exceptionElem = new Element("forth|back", false, true, false);
    exceptionElem.setStringPosException("exception", false, false, false, false, false, "POS", false, false);
    final List<Element> elements = Arrays.asList(
        new Element("move", false, false, false),
        exceptionElem
        );
    final PatternRule rule1 = new PatternRule("RULE1", new English(), elements, "desc", "msg", "shortMsg");
    final Searcher errorSearcher = new Searcher(directory);
    final SearcherResult searcherResult = errorSearcher.findRuleMatchesOnIndex(rule1, new English());
View Full Code Here

TOP

Related Classes of org.languagetool.rules.patterns.Element

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.