Class BERTSuggestionRanking


public class BERTSuggestionRanking extends RemoteRule
reorder suggestions from another rule using BERT as a LM
  • Field Details

  • Constructor Details

  • Method Details

    • prepareSuggestions

      protected List<SuggestedReplacement> prepareSuggestions(List<SuggestedReplacement> suggestions)
      transform suggestions before resorting, e.g. limit resorting to top-n candidates
      Returns:
      transformed suggestions
    • prepareRequest

      protected RemoteRule.RemoteRequest prepareRequest(List<AnalyzedSentence> sentences, Long textSessionId)
      Description copied from class: RemoteRule
      run local preprocessing steps (or just store sentences)
      Specified by:
      prepareRequest in class RemoteRule
      Parameters:
      sentences - text to process
      textSessionId - session ID for caching, partial rollout, A/B testing
      Returns:
      parameter for executeRequest/fallbackResults
    • fallbackResults

      protected RemoteRuleResult fallbackResults(RemoteRule.RemoteRequest request)
      Description copied from class: RemoteRule
      fallback if executeRequest times out or throws an error
      Specified by:
      fallbackResults in class RemoteRule
      Parameters:
      request - returned by prepareRequest
      Returns:
      local results for this rule
    • executeRequest

      protected Callable<RemoteRuleResult> executeRequest(RemoteRule.RemoteRequest request, long timeoutMilliseconds) throws TimeoutException
      Specified by:
      executeRequest in class RemoteRule
      Parameters:
      request - returned by prepareRequest
      timeoutMilliseconds - timeout for this operation, <=0 -> unlimited
      Returns:
      callable that sends request, parses and returns result for this remote rule
      Throws:
      TimeoutException - if timeout was exceeded
    • buildRequest

      @Nullable private RemoteLanguageModel.Request buildRequest(RuleMatch match)
    • getId

      public String getId()
      Description copied from class: Rule
      A string used to identify the rule in e.g. configuration files. This string is supposed to be unique and to stay the same in all upcoming versions of LanguageTool. It's supposed to contain only the characters A-Z and the underscore.
      Overrides:
      getId in class RemoteRule
    • getDescription

      public String getDescription()
      Description copied from class: Rule
      A short description of the error this rule can detect, usually in the language of the text that is checked.
      Specified by:
      getDescription in class Rule