public final class Tools
extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
checkBitext(BitextReader reader,
JLanguageTool srcLt,
JLanguageTool trgLt,
List<BitextRule> bRules,
boolean apiFormat)
Checks the bilingual input (bitext) and displays the output (considering the target
language) in API format or in the simple text format.
|
static List<RuleMatch> |
checkBitext(String src,
String trg,
JLanguageTool srcLt,
JLanguageTool trgLt,
List<BitextRule> bRules)
Checks the bilingual input (bitext) and displays the output (considering the target
language) in API format or in the simple text format.
|
static int |
checkBitext(String src,
String trg,
JLanguageTool srcLt,
JLanguageTool trgLt,
List<BitextRule> bRules,
boolean apiFormat,
StringTools.XmlPrintMode xmlMode)
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,
JLanguageTool lt) |
static int |
checkText(String contents,
JLanguageTool lt,
boolean apiFormat,
int lineOffset) |
static int |
checkText(String contents,
JLanguageTool lt,
boolean apiFormat,
int contextSize,
int lineOffset,
int prevMatches,
StringTools.XmlPrintMode xmlMode)
Check the given text and print results to System.out.
|
static int |
checkText(String contents,
JLanguageTool lt,
int lineOffset) |
static void |
correctBitext(BitextReader reader,
JLanguageTool sourceLt,
JLanguageTool targetLt,
List<BitextRule> bRules)
Automatically applies suggestions to the bilingual text.
|
static String |
correctText(String contents,
JLanguageTool lt)
Automatically applies suggestions to the text.
|
static List<BitextRule> |
getBitextRules(Language source,
Language target)
Gets default bitext rules for a given pair of languages
|
static String |
getFullStackTrace(Throwable e)
Get a stacktrace as a string.
|
static InputStream |
getStream(String filename)
Load a file form the classpath using getResourceAsStream().
|
static long |
median(long[] m) |
static int |
profileRulesOnLine(String contents,
JLanguageTool lt,
Rule rule) |
static void |
profileRulesOnText(String contents,
JLanguageTool lt)
Simple rule profiler - used to run LT on a corpus to see which
rule takes most time.
|
static void |
tagText(String contents,
JLanguageTool lt)
Tags text using the LanguageTool tagger.
|
public static void tagText(String contents,
JLanguageTool lt)
throws IOException
contents - Text to tag.lt - LanguageTool instanceIOExceptionpublic static int checkText(String contents,
JLanguageTool lt)
throws IOException
IOExceptionpublic static int checkText(String contents,
JLanguageTool lt,
int lineOffset)
throws IOException
IOExceptionpublic static int checkText(String contents,
JLanguageTool lt,
boolean apiFormat,
int lineOffset)
throws IOException
IOExceptionpublic static int checkText(String contents,
JLanguageTool lt,
boolean apiFormat,
int contextSize,
int lineOffset,
int prevMatches,
StringTools.XmlPrintMode xmlMode)
throws IOException
contents - a text to check (may be more than one sentence)lt - Initialized LanguageToolapiFormat - whether to print the result in a simple XML formatcontextSize - error text context size: -1 for defaultlineOffset - line number offset to be added to line numbers in matchesprevMatches - number of previously matched rulesxmlMode - mode of xml printout for simple xml outputIOExceptionpublic static int checkBitext(String src,
String trg,
JLanguageTool srcLt,
JLanguageTool trgLt,
List<BitextRule> bRules,
boolean apiFormat,
StringTools.XmlPrintMode xmlMode)
throws IOException
src - Source text.trg - Target text.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.apiFormat - Whether API format should be used.xmlMode - The mode of XML output display.IOExceptionpublic static int checkBitext(BitextReader reader, JLanguageTool srcLt, JLanguageTool trgLt, List<BitextRule> bRules, boolean apiFormat) throws IOException
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.apiFormat - Whether API format should be used.IOExceptionpublic static List<RuleMatch> checkBitext(String src, String trg, JLanguageTool srcLt, JLanguageTool trgLt, List<BitextRule> bRules) throws IOException
src - Source text.trg - Target text.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.IOExceptionpublic static List<BitextRule> getBitextRules(Language source, Language target) throws IOException, ParserConfigurationException, SAXException
source - Source language.target - Target language.IOExceptionParserConfigurationExceptionSAXExceptionpublic static void profileRulesOnText(String contents,
JLanguageTool lt)
throws IOException
contents - - text to checklt - - instance of LanguageToolIOExceptionpublic static int profileRulesOnLine(String contents,
JLanguageTool lt,
Rule rule)
throws IOException
IOExceptionpublic static long median(long[] m)
public static String correctText(String contents,
JLanguageTool lt)
throws IOException
contents - - String to be correctedlt - - Initialized LanguageTool objectIOExceptionpublic static void correctBitext(BitextReader reader, JLanguageTool sourceLt, JLanguageTool targetLt, List<BitextRule> bRules) throws IOException
reader - - a bitext file readersourceLt - Initialized source JLanguageTool objecttargetLt - Initialized target JLanguageTool objectbRules - List of all BitextRules to useIOExceptionpublic static String getFullStackTrace(Throwable e)
public static InputStream getStream(String filename)
throws IOException
filename - IOExceptionCopyright © 2005-2011 Daniel Naber