Examples of activateDefaultPatternRules()


Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

  public void testCompleteText2() throws Exception {
    InputStream stream = SuggestionReplacerTest.class.getResourceAsStream("/org/languagetool/dev/wikipedia/wikipedia2.txt");
    String origMarkup = IOUtils.toString(stream);
    JLanguageTool langTool = new JLanguageTool(new GermanyGerman());
    langTool.activateDefaultPatternRules();
    SwebleWikipediaTextFilter filter = new SwebleWikipediaTextFilter();
    PlainTextMapping mapping = filter.filter(origMarkup);
    List<RuleMatch> matches = langTool.check(mapping.getPlainText());
    assertTrue("Expected >= 30 matches, got: " + matches, matches.size() >= 30);
    String markup = origMarkup;
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

    return langTool;
  }

  private JLanguageTool getLanguageTool(Language language) throws IOException {
    JLanguageTool langTool = new JLanguageTool(language);
    langTool.activateDefaultPatternRules();
    return langTool;
  }

  private void applySuggestion(JLanguageTool langTool, SwebleWikipediaTextFilter filter, String text, String expected) throws IOException {
    PlainTextMapping mapping = filter.filter(text);
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

    //final Language language = new French();
    //final Language language = new Spanish();
    //final Language language = new Polish(); // TODO: still "Clauses must have same field"
    //final Language language = new German();
    final JLanguageTool lt = new JLanguageTool(language);
    lt.activateDefaultPatternRules();
   
    System.out.println("Creating index for " + language + "...");
    final int ruleCount = createIndex(lt);
    System.out.println("Index created with " + ruleCount + " rules");
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

   * @param lang the language to be used.
   * @param motherTongue the user's mother tongue or {@code null}
   */
  private JLanguageTool getLanguageToolInstance(Language lang, Language motherTongue, QueryParams params) throws Exception {
    final JLanguageTool newLanguageTool = new JLanguageTool(lang, motherTongue);
    newLanguageTool.activateDefaultPatternRules();
    newLanguageTool.activateDefaultFalseFriendRules();
    if (languageModelDir != null) {
      newLanguageTool.activateLanguageModelRules(languageModelDir);
    }
    final Configuration config = new Configuration(lang);
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

  @Override
  public void run() {
    try {
      final JLanguageTool langTool = new JLanguageTool(docLanguage, config.getMotherTongue());
      langTool.activateDefaultPatternRules();
      langTool.activateDefaultFalseFriendRules();
      cfgDialog.show(langTool.getAllRules());
      config.saveConfiguration(docLanguage);
      if (mainThread != null) {
        mainThread.resetDocument();
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

      final Rule spellcheckRule = getSpellcheckRule(languageTool);
      if (spellcheckRule == null) {
        System.out.println("No spellchecker rule found for " + lang);
        continue;
      }
      languageTool.activateDefaultPatternRules();
      final List<Rule> rules = languageTool.getAllRules();
      int tokenCount = 0;
      int noErrorCount = 0;
      for (Rule rule : rules) {
        final List<String> tokens = extractor.getSuggestionTokens(rule, lang);
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

  }

  private void initExpectedResults(List<Language> languages) throws IOException {
    for (Language lang : languages) {
      JLanguageTool lt = new JLanguageTool(lang);
      lt.activateDefaultPatternRules();
      String input = examples.get(lang.getShortNameWithCountryAndVariant());
      if (input != null) {
        List<RuleMatch> matches = lt.check(input);
        expectedResults.put(lang.getShortNameWithCountryAndVariant(), toString(matches));
      }
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

    public void run() {
      String input = examples.get(lang.getShortNameWithCountryAndVariant());
      if (input != null) {
        try {
          JLanguageTool lt = new JLanguageTool(lang);
          lt.activateDefaultPatternRules();
          //System.out.println("Running with " + lang.getShortNameWithCountryAndVariant());
          List<RuleMatch> matches = lt.check(input);
          //System.out.println("=>" + matches);
          String expected = expectedResults.get(lang.getShortNameWithCountryAndVariant());
          String real = MultiThreadingTest1.toString(matches);
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

      int beginIndex = rnd.nextInt(text.length());
      int endIndex = Math.min(beginIndex + MAX_TEXT_LENGTH, text.length()-1);
      String subText = text.substring(beginIndex, endIndex);
      long startTime = System.currentTimeMillis();
      JLanguageTool langTool = new MultiThreadedJLanguageTool(language);
      langTool.activateDefaultPatternRules();
      List<RuleMatch> matches = langTool.check(subText);
      long runTime = System.currentTimeMillis() - startTime;
      if (i >= SKIP) {
        totalTime += runTime;
        System.out.println("Time: " + runTime + "ms (" + matches.size() + " matches)");
View Full Code Here

Examples of org.languagetool.JLanguageTool.activateDefaultPatternRules()

      System.out.println("Usage: " + RuleNumberScalabilityTest.class.getSimpleName() + " <languageCode> <text_file>");
      System.exit(1);
    }
    JLanguageTool langTool = new JLanguageTool(Language.getLanguageForShortName(args[0]));
    String text = StringTools.readStream(new FileInputStream(args[1]), "utf-8");
    langTool.activateDefaultPatternRules();
    System.out.println("Warmup...");
    langTool.check(text);
    langTool.check(text);

    long baselineTime = getBaselineTime(langTool, text);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.