Package org.languagetool.language

Examples of org.languagetool.language.English


  private Language language;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    language = new English();
    directory = new RAMDirectory();
    /*final File indexPath = new File("/tmp/lucene");
    if (indexPath.exists()) {
      FileUtils.deleteDirectory(indexPath);
    }
View Full Code Here


  private void run(String filename) throws IOException {
    Map<String, ConfusionProbabilityRule.ConfusionSet> confusionSet = getConfusionSet();
    try (FileReader reader = new FileReader(filename)) {
      String text = StringTools.readerToString(reader);
      JLanguageTool languageTool = new JLanguageTool(new English());
      List<AnalyzedSentence> analyzedSentences = languageTool.analyzeText(text);
      for (AnalyzedSentence sentence : analyzedSentences) {
        runOnSentence(sentence, confusionSet);
      }
    }
View Full Code Here

    final CheckBNC prg = new CheckBNC();
    prg.run(new File(args[0]));
  }
 
  private CheckBNC() throws IOException {
    langTool = new JLanguageTool(new English());
    langTool.activateDefaultPatternRules();
    final String[] disRules = {"UPPERCASE_SENTENCE_START", "COMMA_PARENTHESIS_WHITESPACE",
        "WORD_REPEAT_RULE", "DOUBLE_PUNCTUATION"};
    System.err.println("Note: disabling the following rules:");
    for (String disRule : disRules) {
View Full Code Here

    List<Rule> rules = langTool.getAllActiveRules();
    for (Rule rule : rules) {
      langTool.disableRule(rule.getId());
    }
    languageModel = new LuceneLanguageModel(languageModelIndexDir);
    confusionRule = new EnglishConfusionProbabilityRule(JLanguageTool.getMessageBundle(), languageModel, new English());
    langTool.addRule(confusionRule);
  }
View Full Code Here

    if (indexTopDir != null) {
      if (indexTopDir.isDirectory()) {
        languageModel = new LuceneLanguageModel(indexTopDir);
        System.out.println("Using Lucene language model from " + languageModel);
        EnglishConfusionProbabilityRule probabilityRule =
                new EnglishConfusionProbabilityRule(JLanguageTool.getMessageBundle(), languageModel, new English());
        //new EnglishConfusionProbabilityRule(JLanguageTool.getMessageBundle(), languageModel, new File("/tmp/languagetool_network.net"));
        langTool.addRule(probabilityRule);
      } else {
        throw new RuntimeException("Does not exist or not a directory: " + indexTopDir);
      }
View Full Code Here

import java.io.IOException;

public class WordRepeatRuleTest extends TestCase {

  public void testRule() throws IOException {
    final English english = new English();
    final WordRepeatRule rule = new WordRepeatRule(TestTools.getEnglishMessages(), english);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(english);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("This is a test sentence."));
View Full Code Here

    runGrammarRulesFromXmlTest();
  }

  // used to cause an ArrayIndexOutOfBoundsException in MatchState.setToken()
  public void testBug() throws Exception {
    JLanguageTool langTool = new JLanguageTool(new English());
    langTool.activateDefaultPatternRules();
    langTool.check("Alexander between 369 and 358 BC\n\nAlexander");
  }
View Full Code Here

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    rule = new ContractionSpellingRule(TestTools.getMessages("en"));
    langTool = new JLanguageTool(new English());
  }
View Full Code Here

public class CompoundRuleTest extends AbstractCompoundRuleTest {

  @Override
  protected void setUp() throws Exception {
    super.setUp();
    langTool = new JLanguageTool(new English());
    rule = new CompoundRule(null);
  }
View Full Code Here

          match.getSuggestedReplacements());
    }
  }

  public void testEnglish() throws IOException {
    final JLanguageTool tool = new JLanguageTool(new English());
    assertEquals(0, tool.check("A test that should not give errors.").size());

    //more error-free sentences to deal with possible regressions
    assertEquals(0, tool.check("As long as you have hope, a chance remains.").size());
    assertEquals(0, tool.check("A rolling stone gathers no moss.").size());
View Full Code Here

TOP

Related Classes of org.languagetool.language.English

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.