public final class Tools extends Object
| Modifier and Type | Method and Description |
|---|---|
static List<RuleMatch> |
checkBitext(String src,
String trg,
JLanguageTool srcLt,
JLanguageTool trgLt,
List<BitextRule> bRules)
Checks the bilingual input (bitext).
|
static String |
correctText(String contents,
JLanguageTool lt)
Automatically applies suggestions to the text, as suggested
by the rules that match.
|
static String |
correctTextFromMatches(String contents,
List<RuleMatch> matches) |
static List<BitextRule> |
getBitextRules(Language source,
Language target)
Gets default bitext rules for a given pair of languages
|
static List<BitextRule> |
getBitextRules(Language source,
Language target,
File externalBitextRuleFile)
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 path)
Load a file from the classpath using
Class.getResourceAsStream(String). |
static int |
profileRulesOnLine(String contents,
JLanguageTool lt,
Rule rule) |
static List<BitextRule> |
selectBitextRules(List<BitextRule> bRules,
List<String> disabledRules,
List<String> enabledRules,
boolean useEnabledOnly)
Enable and disable bitext rules.
|
static void |
selectRules(JLanguageTool lt,
List<String> disabledRuleIds,
List<String> enabledRuleIds,
boolean useEnabledOnly)
Enable and disable rules of the given LanguageTool instance.
|
static void |
selectRules(JLanguageTool lt,
String[] disabledRules,
String[] enabledRules)
Enable and disable rules of the given LanguageTool instance.
|
static void |
selectRules(JLanguageTool lt,
String[] disabledRules,
String[] enabledRules,
boolean useEnabledOnly)
Enable and disable rules of the given LanguageTool instance.
|
static void |
setPasswordAuthenticator()
Calls
Authenticator.setDefault() with a password
authenticator so that it's possible to use URLs of the
format http://username:password@server when loading XML files. |
public 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 List<BitextRule> getBitextRules(Language source, Language target, File externalBitextRuleFile) throws IOException, ParserConfigurationException, SAXException
source - Source language.target - Target language.externalBitextRuleFile - external file with bitext rulesIOExceptionParserConfigurationExceptionSAXExceptionpublic static int profileRulesOnLine(String contents, JLanguageTool lt, Rule rule) throws IOException
IOExceptionpublic static String correctText(String contents, JLanguageTool lt) throws IOException
contents - String to be correctedlt - Initialized LanguageTool objectIOExceptionpublic static String correctTextFromMatches(String contents, List<RuleMatch> matches)
public static InputStream getStream(String path) throws IOException
Class.getResourceAsStream(String).IOExceptionpublic static void selectRules(JLanguageTool lt, String[] disabledRules, String[] enabledRules)
lt - LanguageTool objectdisabledRules - ids of the rules to be disabledenabledRules - ids of the rules to be enabledpublic static void selectRules(JLanguageTool lt, List<String> disabledRuleIds, List<String> enabledRuleIds, boolean useEnabledOnly)
lt - LanguageTool objectdisabledRuleIds - ids of the rules to be disabledenabledRuleIds - ids of the rules to be enableduseEnabledOnly - if set to true, disable all rules except those enabled explicitlypublic static void selectRules(JLanguageTool lt, String[] disabledRules, String[] enabledRules, boolean useEnabledOnly)
lt - LanguageTool objectdisabledRules - ids of the rules to be disabledenabledRules - ids of the rules to be enableduseEnabledOnly - if set to true, disable all rules except those enabled explicitlypublic static List<BitextRule> selectBitextRules(List<BitextRule> bRules, List<String> disabledRules, List<String> enabledRules, boolean useEnabledOnly)
bRules - List of all bitext rulesdisabledRules - ids of rules to be disabledenabledRules - ids of rules to be enabled (by default all are enabled)useEnabledOnly - if set to true, if set to true, disable all rules except those enabled explicitly.public static void setPasswordAuthenticator()
Authenticator.setDefault() with a password
authenticator so that it's possible to use URLs of the
format http://username:password@server when loading XML files.
If the password manager doesn't allow calling Authenticator.setDefault(),
this will be silently ignored and the feature of using these URLs
will not be available.