Package org.languagetool.language

Examples of org.languagetool.language.English


    if (!isStdIn(filename)) {
      if (autoDetect) {
        Language language = detectLanguageOfFile(filename, encoding);
        if (language == null) {
          System.err.println("Could not detect language well enough, using English");
          language = new English();
        }
        changeLanguage(language, motherTongue, disabledRules, enabledRules);
        System.out.println("Using " + language.getName() + " for file " + filename);
      }
      final File file = new File(filename);
View Full Code Here


          // to detect language from the first input line
          if (lineCount == 1 && autoDetect) {
            Language language = detectLanguageOfString(line);
            if (language == null) {
              System.err.println("Could not detect language well enough, using English");
              language = new English();
            }
            System.out.println("Language used is: " + language.getName());
            language.getSentenceTokenizer().setSingleLineBreaksMarksParagraph(
                    singleLineBreakMarksParagraph);
            changeLanguage(language, motherTongue, disabledRules, enabledRules);
View Full Code Here

    if (options.getLanguage() == null) {
      if (!options.isApiFormat() && !options.isAutoDetect()) {
        System.err.println("No language specified, using English (no spell checking active, " +
                "specify a language variant like 'en-GB' if available)");
      }
      options.setLanguage(new English());
    } else if (!options.isApiFormat() && !options.isApplySuggestions()) {
      languageHint = "Expected text language: " + options.getLanguage().getName();
    }

    options.getLanguage().getSentenceTokenizer().setSingleLineBreaksMarksParagraph(
View Full Code Here

 
  @Override
  public void setUp() {
    tagger = new EnglishTagger();
    tokenizer = new WordTokenizer();
    sentenceTokenizer = new SRXSentenceTokenizer(new English());
    disambiguator = new XmlRuleDisambiguator(new English());
    disamb2 = new DemoDisambiguator();
  }
View Full Code Here

        // this doesn't work because the output rules file is not a legit rules file
        //TODO: fix this so we can have this functionality
        try {
          if (args[0].equals("--check")) {
            RuleCoverage checker = new RuleCoverage(new English());
            String inFile = args[1];
            checker.evaluateRules(inFile);
            System.exit(1);
          }
        } catch (Exception e) {
View Full Code Here

public class WikipediaSentenceSourceTest {
 
  @Test
  public void testWikipediaSource() throws XMLStreamException, IOException {
    InputStream stream = WikipediaSentenceSourceTest.class.getResourceAsStream("/org/languagetool/dev/wikipedia/wikipedia-en.xml");
    WikipediaSentenceSource source = new WikipediaSentenceSource(stream, new English());
    assertTrue(source.hasNext());
    assertThat(source.next().getText(), is("This is the first document."));
    assertThat(source.next().getText(), is("It has three sentences."));
    assertThat(source.next().getText(), is("Here's the last sentence."));
   
View Full Code Here

public class TatoebaSentenceSourceTest {
 
  @Test
  public void testTatoebaSource() {
    InputStream stream = WikipediaSentenceSourceTest.class.getResourceAsStream("/org/languagetool/dev/wikipedia/tatoeba-en.txt");
    TatoebaSentenceSource source = new TatoebaSentenceSource(stream, new English());
    assertTrue(source.hasNext());
    assertThat(source.next().getText(), is("\"What is your wish?\" asked the little white rabbit."));
    assertThat(source.next().getText(), is("The mother wakes up her daughter."));
    assertThat(source.next().getText(), is("Ken beat me at chess."));
    assertFalse(source.hasNext());
View Full Code Here

 
  public void testFilter() throws Exception {
    final String input = "How to?";

    final TokenStream stream = new AnyCharTokenizer(TEST_VERSION_CURRENT, new StringReader(input));
    final LanguageToolFilter filter = new LanguageToolFilter(stream, new JLanguageTool(new English()), false);
    //displayTokensWithFullDetails(filter);

    String start = "_POS_SENT_START";
    assertTokenStreamContents(filter,
        new String[] { start, "How", "_LEMMA_how", "_POS_WRB", "to",   "_LEMMA_to", "_POS_TO", "_LEMMA_to", "_POS_IN", "?",    "_POS_SENT_END" },
View Full Code Here

    // comment in to test with external index:
    //directory = new SimpleFSDirectory(new File("/media/external-disk/corpus/languagetool/fast-rule-evaluation-de/"));
    //errorSearcher = new Searcher(directory);

    // TODO: make this work for all languages
    final Language language = new English();
    //final Language language = new French();
    //final Language language = new Spanish();
    //final Language language = new Polish();
    //final Language language = new German();
    final JLanguageTool lt = new JLanguageTool(language);
View Full Code Here

  }

  public void testIndexerSearcherWithEnglish() throws Exception {
    // Note that the second sentence ends with "lid" instead of "lids" (the inflated one)
    createIndex("How to move back and fourth from linux to xmb? Calcium deposits on eye lid.");
    English language = new English();
    SearcherResult searcherResult =
        errorSearcher.findRuleMatchesOnIndex(getFirstRule("BACK_AND_FOURTH", language), language);
    assertEquals(2, searcherResult.getCheckedSentences());
    assertEquals(false, searcherResult.isResultIsTimeLimited());
    assertEquals(1, searcherResult.getMatchingSentences().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.