Class RemoteRuleConfig

java.lang.Object
org.languagetool.rules.RemoteRuleConfig

public class RemoteRuleConfig extends Object
  • Field Details

    • DEFAULT_PORT

      private static final int DEFAULT_PORT
      See Also:
    • DEFAULT_BASE_TIMEOUT

      private static final long DEFAULT_BASE_TIMEOUT
      See Also:
    • DEFAULT_TIMEOUT_PER_CHAR

      private static final float DEFAULT_TIMEOUT_PER_CHAR
      See Also:
    • DEFAULT_DOWN

      private static final long DEFAULT_DOWN
      See Also:
    • DEFAULT_FAILURE_RATE_THRESHOLD

      private static final float DEFAULT_FAILURE_RATE_THRESHOLD
      See Also:
    • DEFAULT_SLIDING_WINDOW_TYPE

      private static final String DEFAULT_SLIDING_WINDOW_TYPE
    • DEFAULT_SLIDING_WINDOW_SIZE

      private static final int DEFAULT_SLIDING_WINDOW_SIZE
      See Also:
    • DEFAULT_MINIMUM_NUMBER_OF_CALLS

      private static final int DEFAULT_MINIMUM_NUMBER_OF_CALLS
      See Also:
    • THIRD_PARTY_AI

      public static final String THIRD_PARTY_AI
      See Also:
    • FALLBACK_RULE_ID

      public static final String FALLBACK_RULE_ID
      See Also:
    • PREMIUM

      public static final String PREMIUM
      See Also:
    • configCache

      private static final com.google.common.cache.LoadingCache<File,List<RemoteRuleConfig>> configCache
    • ruleId

      public String ruleId
    • url

      public String url
    • port

      public Integer port
    • baseTimeoutMilliseconds

      public long baseTimeoutMilliseconds
    • timeoutPerCharacterMilliseconds

      public float timeoutPerCharacterMilliseconds
    • downMilliseconds

      public long downMilliseconds
    • failureRateThreshold

      public float failureRateThreshold
    • slidingWindowType

      public String slidingWindowType
    • slidingWindowSize

      public int slidingWindowSize
    • minimumNumberOfCalls

      public int minimumNumberOfCalls
    • options

      public Map<String,String> options
    • language

      public String language
    • type

      public String type
  • Constructor Details

    • RemoteRuleConfig

      public RemoteRuleConfig()
    • RemoteRuleConfig

      public RemoteRuleConfig(RemoteRuleConfig copy)
  • Method Details

    • getRelevantConfig

      public static RemoteRuleConfig getRelevantConfig(String rule, List<RemoteRuleConfig> configs)
    • isRelevantConfig

      public static Predicate<RemoteRuleConfig> isRelevantConfig(String type, Language language)
    • parse

      public static List<RemoteRuleConfig> parse(InputStream json) throws IOException
      Throws:
      IOException
    • load

      public static List<RemoteRuleConfig> load(File configFile) throws ExecutionException
      Throws:
      ExecutionException
    • getFailureRateThreshold

      public float getFailureRateThreshold()
    • getSlidingWindowType

      public String getSlidingWindowType()
    • getSlidingWindowSize

      public int getSlidingWindowSize()
    • getRuleId

      public String getRuleId()
    • getUrl

      public String getUrl()
    • getPort

      public int getPort()
    • getDownMilliseconds

      public long getDownMilliseconds()
    • getBaseTimeoutMilliseconds

      public long getBaseTimeoutMilliseconds()
    • getTimeoutPerCharacterMilliseconds

      public float getTimeoutPerCharacterMilliseconds()
    • getMinimumNumberOfCalls

      public int getMinimumNumberOfCalls()
    • getOptions

      public Map<String,String> getOptions()
      miscellaneous options for remote rules allows implementing additional behavior in subclasses some options defined in RemoteRule: fixOffsets: boolean - adjust offsets of matches because of discrepancies in string length for some unicode characters between Java and Python filterMatches: boolean - enable anti-patterns from remote-rule-filters.xml suppressMisspelledMatch: regex - filter out matches with matching rule IDs that have misspelled suggestions suppressMisspelledSuggestions: regex - filter out misspelled suggestions from matches with matching rule IDs
    • getLanguage

      public String getLanguage()
      Regex to match language codes for which this rule should be applied
    • getType

      public String getType()
      Identifier for the implementation of RemoteRule that this configuration is meant for
    • isUsingThirdPartyAI

      public boolean isUsingThirdPartyAI()
      based on options
      Returns:
      whether the RemoteRule sends data to a third-party AI model
    • isPremium

      public boolean isPremium()
      based on options
      Returns:
      whether the RemoteRule sends data to a third-party AI model
    • getFallbackRuleId

      public String getFallbackRuleId()
      Gets the ID of the fallback rule to use when this rule is not available (e.g., if this is a third-party AI rule and user has opted out)
      Returns:
      the ID of the fallback rule, or null if no fallback is configured
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object