Package org.languagetool.commandline
Class CommandLineTools
java.lang.Object
org.languagetool.commandline.CommandLineTools
- Since:
- 2.3
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
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
Tags text using the LanguageTool tagger, printing results to System.out.
-
Field Details
-
DEFAULT_CONTEXT_SIZE
private static final int DEFAULT_CONTEXT_SIZE- See Also:
-
-
Constructor Details
-
CommandLineTools
private CommandLineTools()
-
-
Method Details
-
tagText
Tags text using the LanguageTool tagger, printing results to System.out.- Parameters:
contents
- Text to tag.lt
- LanguageTool instance- Throws:
IOException
-
checkText
- 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 LanguageToolisXmlFormat
- whether to print the result in XML formatisJsonFormat
- whether to print the result in JSON formatcontextSize
- error text context size: -1 for defaultlineOffset
- line number offset to be added to line numbers in matchesprevMatches
- number of previously matched rulesapiMode
- 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 checklt
- 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 readersourceLt
- Initialized source JLanguageTool objecttargetLt
- Initialized target JLanguageTool objectbRules
- List of all BitextRules to use- Throws:
IOException
-
correctTextFromMatches
-