Search in sources :

Example 1 with TabBitextReader

use of org.languagetool.bitext.TabBitextReader in project languagetool by languagetool-org.

the class Main method runOnFile.

private void runOnFile(String filename, String encoding, boolean xmlFiltering) throws IOException {
    if (bitextMode) {
        TabBitextReader reader = new TabBitextReader(filename, encoding);
        if (options.isApplySuggestions()) {
            CommandLineTools.correctBitext(reader, srcLt, lt, bRules);
        } else {
            CommandLineTools.checkBitext(reader, srcLt, lt, bRules, options.isXmlFormat());
        }
    } else {
        String text = getFilteredText(filename, encoding, xmlFiltering);
        if (isStdIn(filename)) {
            System.err.println("Working on STDIN...");
        } else {
            System.err.println("Working on " + filename + "...");
        }
        if (options.isAutoDetect()) {
            Language language = detectLanguageOfString(text);
            if (language == null) {
                System.err.println("Could not detect language well enough, using American English");
                language = new AmericanEnglish();
            }
            changeLanguage(language, options.getMotherTongue(), options.getDisabledRules(), options.getEnabledRules());
            System.err.println("Using " + language.getName() + " for file " + filename);
        }
        if (options.isApplySuggestions()) {
            System.out.print(Tools.correctText(text, lt));
        } else if (profileRules) {
            CommandLineTools.profileRulesOnText(text, lt);
        } else if (!options.isTaggerOnly()) {
            CommandLineTools.checkText(text, lt, options.isXmlFormat(), options.isJsonFormat(), 0, options.isListUnknown());
        } else {
            CommandLineTools.tagText(text, lt);
        }
        if (options.isListUnknown() && !options.isXmlFormat() && !options.isJsonFormat()) {
            System.out.println("Unknown words: " + lt.getUnknownWords());
        }
    }
}
Also used : Language(org.languagetool.Language) AmericanEnglish(org.languagetool.language.AmericanEnglish) TabBitextReader(org.languagetool.bitext.TabBitextReader) StringTools.readerToString(org.languagetool.tools.StringTools.readerToString)

Aggregations

Language (org.languagetool.Language)1 TabBitextReader (org.languagetool.bitext.TabBitextReader)1 AmericanEnglish (org.languagetool.language.AmericanEnglish)1 StringTools.readerToString (org.languagetool.tools.StringTools.readerToString)1