code: public static String applyReplacements(CharSequence word, LinkedHashMap<String, String> replacements) {
      // quite horrible from performance point of view; this should really be a transducer.
      StringBuilder sb = new StringBuilder(word);
      for (final Map.Entry<String, String> e : replacements.entrySet()) {
        String key = e.getKey();
        int index = sb.indexOf(e.getKey());
        while (index != -1) {
          sb.replace(index, index + key.length(), e.getValue());
          index = sb.indexOf(key, index + key.length());
        }
      }
      return sb.toString();
    }
docs: Apply partial string replacements from a given map.
  
  Useful if the word needs to be normalized somehow (i.e., ligatures,
  apostrophes and such).
  
  @param word The word to apply replacements to.
  @param replacements A map of replacements (from-&gt;to).
  @return new string with all replacements applied.