class XmlRuleDisambiguator extends AbstractDisambiguator {

  private static final String DISAMBIGUATION_FILE = "disambiguation.xml";
  private static final String GLOBAL_DISAMBIGUATION_FILE = "disambiguation-global.xml";

  private final RuleSet disambiguationRules;
  
  public XmlRuleDisambiguator(Language language) {
    // by default, don't use global disambiguation (for now)
    this(language, false);
  }

  public XmlRuleDisambiguator(Language language, boolean useGlobalDisambiguation) {
    Objects.requireNonNull(language);
    String disambiguationFile = language.getShortCode() + "/" + DISAMBIGUATION_FILE;
    List<DisambiguationPatternRule> disambiguationRulesList;
    try {
      disambiguationRulesList = loadPatternRules(disambiguationFile, language);
    } catch (Exception e) {
      throw new RuntimeException("Problems with loading disambiguation file: " + disambiguationFile, e);
    }
    if (useGlobalDisambiguation) {
      // disambiguation-global.xml
      try {
        disambiguationRulesList.addAll(loadPatternRules(GLOBAL_DISAMBIGUATION_FILE, language));
      } catch (Exception e) {
        throw new RuntimeException("Problems with loading global disambiguation file: " + GLOBAL_DISAMBIGUATION_FILE, e);
      }
    }
    disambiguationRules = RuleSet.textHinted(disambiguationRulesList);
  }

  @Override
  public AnalyzedSentence disambiguate(AnalyzedSentence input) throws IOException {
    return disambiguate(input, null);
  }

  @Override
  public AnalyzedSentence disambiguate(AnalyzedSentence sentence,
      @Nullable JLanguageTool.CheckCancelledCallback checkCanceled) throws IOException {<FILL_FUNCTION_BODY>}

  /**
   * Load disambiguation rules from an XML file. Use {@link JLanguageTool#addRule}
   * to add these rules to the checking process.
   * 
   * @return a List of {@link DisambiguationPatternRule} objects
   */
  protected List<DisambiguationPatternRule> loadPatternRules(String filename, Language language)
      throws ParserConfigurationException, SAXException, IOException {
    DisambiguationRuleLoader ruleLoader = new DisambiguationRuleLoader();
    return ruleLoader.getRules(JLanguageTool.getDataBroker().getFromResourceDirAsStream(filename), language, filename);
  }

}

    for (Rule rule : disambiguationRules.rulesForSentence(sentence)) {
      if (checkCanceled != null && checkCanceled.checkCancelled()) {
        break;
      }
      sentence = ((DisambiguationPatternRule) rule).replace(sentence);
    }
    return sentence;
  
<methods>public non-sealed void <init>() ,public org.languagetool.AnalyzedSentence preDisambiguate(org.languagetool.AnalyzedSentence) <variables>