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 LinguServices |
getLinguisticServices()
since 5.7
|
static InputStream |
getStream(String path)
Load a file from the classpath using
Class.getResourceAsStream(String). |
static URL |
getUrl(String url)
Create a URL object from a string.
|
static String |
i18n(ResourceBundle messages,
String key,
Object... messageArguments)
Translate a text string based on our i18n files.
|
static boolean |
isExternSpeller()
since 5.7
|
static boolean |
isParagraphEnd(List<AnalyzedSentence> sentences,
int nTest,
Language lang) |
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,
Set<CategoryId> disabledCategories,
Set<CategoryId> enabledCategories,
Set<String> disabledRules,
Set<String> enabledRules,
boolean useEnabledOnly,
boolean enableTempOff) |
static void |
setLinguisticServices(LinguServices ls)
set linguistic services (only to introduce external speller for LT)
since 5.7
|
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 String i18n(ResourceBundle messages, String key, Object... messageArguments)
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).
Please load files in the rules and resource directories with
ResourceDataBroker instead.IOExceptionpublic 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, Set<CategoryId> disabledCategories, Set<CategoryId> enabledCategories, Set<String> disabledRules, Set<String> enabledRules, boolean useEnabledOnly, boolean enableTempOff)
public 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.public static URL getUrl(String url)
MalformedURLException into a RuntimeException.public static boolean isParagraphEnd(List<AnalyzedSentence> sentences, int nTest, Language lang)
public static void setLinguisticServices(LinguServices ls)
public static boolean isExternSpeller()
public static LinguServices getLinguisticServices()