Class CommandLineTools


  • public final class CommandLineTools
    extends java.lang.Object
    Since:
    2.3
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CommandLineTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int checkBitext​(org.languagetool.bitext.BitextReader reader, org.languagetool.JLanguageTool srcLt, org.languagetool.JLanguageTool trgLt, java.util.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​(java.lang.String contents, org.languagetool.JLanguageTool lt)  
      static int checkText​(java.lang.String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset)  
      static int checkText​(java.lang.String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int lineOffset, boolean listUnknownWords)  
      static int checkText​(java.lang.String contents, org.languagetool.JLanguageTool lt, boolean isXmlFormat, boolean isJsonFormat, int contextSize, int lineOffset, int prevMatches, org.languagetool.tools.StringTools.ApiPrintMode apiMode, boolean listUnknownWords, java.util.List<java.lang.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, java.util.List<org.languagetool.rules.bitext.BitextRule> bRules)
      Automatically applies suggestions to the bilingual text.
      private static java.lang.String correctTextFromMatches​(java.lang.String contents, java.util.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​(java.util.List<org.languagetool.rules.RuleMatch> ruleMatches, int prevMatches, java.lang.String contents, int contextSize)
      Displays matches in a simple text format.
      static void profileRulesOnText​(java.lang.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​(java.lang.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
    • Constructor Detail

      • CommandLineTools

        private CommandLineTools()
    • Method Detail

      • tagText

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

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

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

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

        public static int checkText​(java.lang.String contents,
                                    org.languagetool.JLanguageTool lt,
                                    boolean isXmlFormat,
                                    boolean isJsonFormat,
                                    int contextSize,
                                    int lineOffset,
                                    int prevMatches,
                                    org.languagetool.tools.StringTools.ApiPrintMode apiMode,
                                    boolean listUnknownWords,
                                    java.util.List<java.lang.String> unknownWords)
                             throws java.io.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:
        java.io.IOException
      • displayTimeStats

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

        private static void printMatches​(java.util.List<org.languagetool.rules.RuleMatch> ruleMatches,
                                         int prevMatches,
                                         java.lang.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,
                                      java.util.List<org.languagetool.rules.bitext.BitextRule> bRules,
                                      boolean isXmlFormat)
                               throws java.io.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:
        java.io.IOException
        Since:
        1.0.1
      • profileRulesOnText

        public static void profileRulesOnText​(java.lang.String contents,
                                              org.languagetool.JLanguageTool lt)
                                       throws java.io.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:
        java.io.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,
                                         java.util.List<org.languagetool.rules.bitext.BitextRule> bRules)
                                  throws java.io.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:
        java.io.IOException
      • correctTextFromMatches

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