public abstract class GRPCRule extends RemoteRule
public List<Rule> getRelevantRemoteRules(ResourceBundle messageBundle, List<RemoteRuleConfig> configs, GlobalConfig globalConfig, UserConfig userConfig, Language motherTongue, List<Language> altLanguages) throws IOException { List<Rule> rules = new ArrayList<>(super.getRelevantRemoteRules( messageBundle, configs, globalConfig, userConfig, motherTongue, altLanguages)); Rule exampleRule = GRPCRule.create(messageBundle, RemoteRuleConfig.getRelevantConfig("EXAMPLE_ID", configs), "EXAMPLE_ID", "example_rule_id", Collections.singletonMap("example_match_id", "example_rule_message")); rules.add(exampleRule); return rules; }
Modifier and Type | Class and Description |
---|---|
protected class |
GRPCRule.AnalyzedMLRuleRequest |
static class |
GRPCRule.Connection |
static class |
GRPCRule.GRPCSubRule
Internal rule to create rule matches with IDs based on Match Sub-IDs
|
protected class |
GRPCRule.MLRuleRequest |
RemoteRule.RemoteRequest
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_TYPE |
static String |
WHITESPACE_REGEX |
circuitBreakers, filterMatches, fixOffsets, inputLogging, lt, premium, ruleLanguage, serviceConfiguration, shutdownRoutines, suppressMisspelledMatch, suppressMisspelledSuggestions, whitespaceNormalisation
Constructor and Description |
---|
GRPCRule(Language language,
ResourceBundle messages,
RemoteRuleConfig config,
boolean inputLogging) |
Modifier and Type | Method and Description |
---|---|
static String |
cleanID(String id) |
static GRPCRule |
create(Language language,
RemoteRuleConfig config,
boolean inputLogging,
String id,
String description,
Map<String,String> messagesByID)
Helper method to create instances of RemoteMLRule
|
static GRPCRule |
create(Language language,
ResourceBundle messages,
RemoteRuleConfig config,
boolean inputLogging,
String id,
String descriptionKey,
Map<String,String> messagesByID)
Helper method to create instances of RemoteMLRule
|
static List<GRPCRule> |
createAll(Language language,
List<RemoteRuleConfig> configs,
boolean inputLogging) |
static List<GRPCRule> |
createAll(Language language,
List<RemoteRuleConfig> configs,
boolean inputLogging,
String prefix,
String defaultDescription) |
protected Callable<RemoteRuleResult> |
executeRequest(RemoteRule.RemoteRequest requestArg,
long timeoutMilliseconds) |
protected RemoteRuleResult |
fallbackResults(RemoteRule.RemoteRequest request)
fallback if executeRequest times out or throws an error
|
protected abstract String |
getMessage(MLServerProto.Match match,
AnalyzedSentence sentence)
messages can be provided by the ML server or the Java client
fill them in here or leave this empty if the server takes care of it
|
protected RemoteRule.RemoteRequest |
prepareRequest(List<AnalyzedSentence> sentences,
Long textSessionId)
run local preprocessing steps (or just store sentences)
|
circuitBreaker, createCircuitBreaker, fixMatchOffsets, getId, getServiceConfiguration, getTimeout, isPremium, match, run, run, shutdown
addExamplePair, addTags, addToneTags, cacheAntiPatterns, estimateContextForSureMatch, getAntiPatterns, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getDescription, getDistanceTokens, getErrorTriggeringExamples, getFullId, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getMinPrevMatches, getSentenceWithImmunization, getSourceFile, getSubId, getTags, getToneTags, getUrl, hasConfigurableValue, hasTag, hasToneTag, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isGoalSpecific, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setDistanceTokens, setErrorTriggeringExamples, setExamplePair, setGoalSpecific, setIncorrectExamples, setLocQualityIssueType, setMinPrevMatches, setOfficeDefaultOff, setOfficeDefaultOn, setPremium, setTags, setToneTags, setUrl, supportsLanguage, toRuleMatchArray, useInOffice
public static final String CONFIG_TYPE
public static final String WHITESPACE_REGEX
public GRPCRule(Language language, ResourceBundle messages, RemoteRuleConfig config, boolean inputLogging)
protected RemoteRule.RemoteRequest prepareRequest(List<AnalyzedSentence> sentences, @Nullable Long textSessionId)
RemoteRule
prepareRequest
in class RemoteRule
sentences
- text to processtextSessionId
- session ID for caching, partial rollout, A/B testingprotected Callable<RemoteRuleResult> executeRequest(RemoteRule.RemoteRequest requestArg, long timeoutMilliseconds) throws TimeoutException
executeRequest
in class RemoteRule
requestArg
- returned by prepareRequesttimeoutMilliseconds
- timeout for this operation, <=0 -> unlimitedTimeoutException
- if timeout was exceededprotected abstract String getMessage(MLServerProto.Match match, AnalyzedSentence sentence)
protected RemoteRuleResult fallbackResults(RemoteRule.RemoteRequest request)
RemoteRule
fallbackResults
in class RemoteRule
request
- returned by prepareRequestpublic static GRPCRule create(Language language, ResourceBundle messages, RemoteRuleConfig config, boolean inputLogging, String id, String descriptionKey, Map<String,String> messagesByID)
language
- rule languagemessages
- for i18n; = JLanguageTool.getMessageBundle(lang)config
- configuration for remote rule server;
options: secure, clientKey, clientCertificate, rootCertificate
use RemoteRuleConfig.getRelevantConfig(id, configs)
to load this in Language::getRelevantRemoteRulesid
- ID of ruledescriptionKey
- key in MessageBundle.properties for rule descriptionmessagesByID
- mapping match.sub_id -> key in MessageBundle.properties for RuleMatch's messagepublic static GRPCRule create(Language language, RemoteRuleConfig config, boolean inputLogging, String id, String description, Map<String,String> messagesByID)
language
- rule languageconfig
- configuration for remote rule server;
options: secure, clientKey, clientCertificate, rootCertificate
use RemoteRuleConfig.getRelevantConfig(id, configs)
to load this in Language::getRelevantRemoteRulesid
- ID of ruledescription
- rule descriptionmessagesByID
- mapping match.sub_id to RuleMatch's messagepublic static List<GRPCRule> createAll(Language language, List<RemoteRuleConfig> configs, boolean inputLogging, String prefix, String defaultDescription)
public static List<GRPCRule> createAll(Language language, List<RemoteRuleConfig> configs, boolean inputLogging)