Package org.languagetool.language

Examples of org.languagetool.language.Demo


public class PatternRuleXmlCreatorTest extends TestCase {

  public void testToXML() throws IOException {
    PatternRuleId ruleId = new PatternRuleId("DEMO_RULE");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertEquals(
            "<rule id=\"DEMO_RULE\" name=\"Find 'foo bar'\"><!-- a trivial demo rule that matches \"foo\" followed by \"bar\" -->\n" +
            "  <pattern case_sensitive=\"no\">\n" +
            "    <token>foo</token>\n" +
            "    <token>bar</token>\n" +
View Full Code Here


  }

  public void testToXMLWithRuleGroup() throws IOException {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertTrue(xml.contains("<rulegroup id=\"test_spacebefore\""));
    assertTrue(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<rule>"));
    assertTrue(xml.contains("<rule type=\"duplication\">"));
    assertTrue(xml.contains("<token>blah</token>"));
View Full Code Here

  }

  public void testToXMLWithRuleGroupAndSubId1() throws IOException {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore", "1");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertFalse(xml.contains("<rulegroup"));
    assertFalse(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<message>This is a dummy message 1.</message>"));
  }
View Full Code Here

  }

  public void testToXMLWithRuleGroupAndSubId2() throws IOException {
    PatternRuleId ruleId = new PatternRuleId("test_spacebefore", "2");
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    String xml = creator.toXML(ruleId, new Demo());
    assertFalse(xml.contains("<rulegroup id=\"test_spacebefore\""));
    assertFalse(xml.contains("</rulegroup>"));
    assertTrue(xml.contains("<message>This is a dummy message 2.</message>"));
  }
View Full Code Here

  public void testToXMLInvalidRuleId() throws IOException {
    PatternRuleXmlCreator creator = new PatternRuleXmlCreator();
    PatternRuleId fakeRuleId = new PatternRuleId("FAKE_ID");
    try {
      creator.toXML(fakeRuleId, new Demo());
      fail();
    } catch(RuntimeException expected) {}
  }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    tagger = new ManualTaggerAdapter(new ManualTagger(new ByteArrayInputStream(TEST_DATA.getBytes("UTF-8"))));
    synthesizer = new ManualSynthesizerAdapter(new ManualSynthesizer(new ByteArrayInputStream(TEST_DATA.getBytes("UTF-8"))));
    languageTool = new JLanguageTool(new Demo() {
      @Override
      public String getName() {
        return "TEST";
      }
      @Override
View Full Code Here

  public void testGrammarRulesFromXML2() throws IOException {
    new PatternRule("-1", Language.DEMO, Collections.<Element>emptyList(), "", "", "");
  }

  public void testDemoLanguageGrammarRules() throws IOException {
    runTestForLanguage(new Demo());
  }
View Full Code Here

  private static final English english = new English();

  @Test
  public void testGetAllActiveRules() throws Exception {
    JLanguageTool langTool = new JLanguageTool(new Demo());
    langTool.activateDefaultPatternRules();
    List<String> ruleIds = getActiveRuleIds(langTool);
    assertTrue(ruleIds.contains("DEMO_RULE"));
    assertFalse(ruleIds.contains("DEMO_RULE_OFF"));
    for (Rule rule : langTool.getAllRules()) {
View Full Code Here

  @Test
  public void testCheck() throws IOException {
    JLanguageTool tool;
   
    tool = new MultiThreadedJLanguageTool(new Demo());
    final List<String> ruleMatchIds1 = getRuleMatchIds(tool);
    assertTrue(ruleMatchIds1.size() == 10);
    Assert.assertEquals(4, tool.getSentenceCount());
   
    tool = new JLanguageTool(new Demo());
    final List<String> ruleMatchIds2 = getRuleMatchIds(tool);
    assertThat(ruleMatchIds1, is(ruleMatchIds2));
    Assert.assertEquals(4, tool.getSentenceCount());
  }
View Full Code Here

    Assert.assertEquals(4, tool.getSentenceCount());
  }
 
  @Test
  public void testTextAnalysis() throws IOException {
    JLanguageTool tool = new MultiThreadedJLanguageTool(new Demo());
    List<AnalyzedSentence> analyzedSentences = tool.analyzeText("This is a sentence. And another one.");
    assertThat(analyzedSentences.size(), is(2));
    assertThat(analyzedSentences.get(0).getTokens().length, is(10));
    assertThat(analyzedSentences.get(0).getTokensWithoutWhitespace().length, is(6))// sentence start has its own token
    assertThat(analyzedSentences.get(1).getTokens().length, is(7));
View Full Code Here

TOP

Related Classes of org.languagetool.language.Demo

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.