Class CommandLineTools

java.lang.Object
org.languagetool.commandline.CommandLineTools

public final class CommandLineTools extends Object
Since:
2.3
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    checkBitext(org.languagetool.bitext.BitextReader reader, org.languagetool.JLanguageTool srcLt, org.languagetool.JLanguageTool trgLt, List<org.languagetool.rules.bitext.BitextRule> bRules, boolean isXmlFormat)
    Checks the bilingual input (bitext) and displays the output (considering the target language) in API format or in the simple text format.
    static int
    checkText(String contents, org.languagetool.JLanguageTool lt)
     
    static int
    checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset)
     
    static int
    checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset, boolean listUnknownWords)
     
    static int
    checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int contextSize, int lineOffset, int prevMatches, org.languagetool.tools.StringTools.ApiPrintMode apiMode, boolean listUnknownWords, List<String> unknownWords)
    Check the given text and print results to System.out.
    static void
    correctBitext(org.languagetool.bitext.BitextReader reader, org.languagetool.JLanguageTool sourceLt, org.languagetool.JLanguageTool targetLt, List<org.languagetool.rules.bitext.BitextRule> bRules)
    Automatically applies suggestions to the bilingual text.
    private static String
    correctTextFromMatches(String contents, List<org.languagetool.rules.RuleMatch> matches)
     
    private static void
    displayTimeStats(long startTime, long sentCount, boolean isXmlFormat)
     
    private static long
    median(long[] m)
     
    private static void
    printMatches(List<org.languagetool.rules.RuleMatch> ruleMatches, int prevMatches, String contents, int contextSize)
    Displays matches in a simple text format.
    static void
    profileRulesOnText(String contents, org.languagetool.JLanguageTool lt)
    Simple rule profiler - used to run LT on a corpus to see which rule takes most time.
    static void
    tagText(String contents, org.languagetool.JLanguageTool lt)
    Tags text using the LanguageTool tagger, printing results to System.out.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CommandLineTools

      private CommandLineTools()
  • Method Details

    • tagText

      public static void tagText(String contents, org.languagetool.JLanguageTool lt) throws IOException
      Tags text using the LanguageTool tagger, printing results to System.out.
      Parameters:
      contents - Text to tag.
      lt - LanguageTool instance
      Throws:
      IOException
    • checkText

      public static int checkText(String contents, org.languagetool.JLanguageTool lt) throws IOException
      Throws:
      IOException
    • checkText

      public static int checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset) throws IOException
      Throws:
      IOException
    • checkText

      public static int checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset, boolean listUnknownWords) throws IOException
      Throws:
      IOException
    • checkText

      public static int checkText(String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int contextSize, int lineOffset, int prevMatches, org.languagetool.tools.StringTools.ApiPrintMode apiMode, boolean listUnknownWords, List<String> unknownWords) throws IOException
      Check the given text and print results to System.out.
      Parameters:
      contents - a text to check (may be more than one sentence)
      lt - Initialized LanguageTool
      isXmlFormat - whether to print the result in XML format
      isJsonFormat - whether to print the result in JSON format
      contextSize - error text context size: -1 for default
      lineOffset - line number offset to be added to line numbers in matches
      prevMatches - number of previously matched rules
      apiMode - mode of xml/json printout for simple xml/json output
      Returns:
      Number of rule matches to the input text.
      Throws:
      IOException
    • displayTimeStats

      private static void displayTimeStats(long startTime, long sentCount, boolean isXmlFormat)
    • printMatches

      private static void printMatches(List<org.languagetool.rules.RuleMatch> ruleMatches, int prevMatches, String contents, int contextSize)
      Displays matches in a simple text format.
      Parameters:
      ruleMatches - Matches from rules.
      prevMatches - Number of previously found matches.
      contents - The text that was checked.
      contextSize - The size of contents displayed.
      Since:
      1.0.1
    • checkBitext

      public static int checkBitext(org.languagetool.bitext.BitextReader reader, org.languagetool.JLanguageTool srcLt, org.languagetool.JLanguageTool trgLt, List<org.languagetool.rules.bitext.BitextRule> bRules, boolean isXmlFormat) throws IOException
      Checks the bilingual input (bitext) and displays the output (considering the target language) in API format or in the simple text format. NOTE: the positions returned by the rule matches are adjusted according to the data returned by the reader.
      Parameters:
      reader - Reader of bitext strings.
      srcLt - Source JLanguageTool (used to analyze the text).
      trgLt - Target JLanguageTool (used to analyze the text).
      bRules - Bilingual rules used in addition to target standard rules.
      Returns:
      The number of rules matched on the bitext.
      Throws:
      IOException
      Since:
      1.0.1
    • profileRulesOnText

      public static void profileRulesOnText(String contents, org.languagetool.JLanguageTool lt) throws IOException
      Simple rule profiler - used to run LT on a corpus to see which rule takes most time. Prints results to System.out.
      Parameters:
      contents - text to check
      lt - instance of LanguageTool
      Throws:
      IOException
    • median

      private static long median(long[] m)
    • correctBitext

      public static void correctBitext(org.languagetool.bitext.BitextReader reader, org.languagetool.JLanguageTool sourceLt, org.languagetool.JLanguageTool targetLt, List<org.languagetool.rules.bitext.BitextRule> bRules) throws IOException
      Automatically applies suggestions to the bilingual text. Note: if there is more than one suggestion, always the first one is applied, and others ignored silently. Prints results to System.out.
      Parameters:
      reader - a bitext file reader
      sourceLt - Initialized source JLanguageTool object
      targetLt - Initialized target JLanguageTool object
      bRules - List of all BitextRules to use
      Throws:
      IOException
    • correctTextFromMatches

      private static String correctTextFromMatches(String contents, List<org.languagetool.rules.RuleMatch> matches)