### Question:
Scorer { public static double computeAccuracy(Map<String, Integer> gold, Map<String, Integer> predictions) throws IllegalArgumentException { if (gold == null) { throw new IllegalArgumentException("Parameter 'gold' is null"); } if (predictions == null) { throw new IllegalArgumentException("Parameter 'predictions' is null"); } if (gold.isEmpty()) { throw new IllegalArgumentException("Parameter 'gold' is an empty map"); } if (predictions.isEmpty()) { throw new IllegalArgumentException("Parameter 'predictions' is an empty map"); } if (!(gold.keySet().containsAll(predictions.keySet()) && predictions.keySet() .containsAll(gold.keySet()))) { throw new IllegalArgumentException( "Gold set and predictions contain different instance IDs"); } Set<String> correctPredictions = new TreeSet<>(); Set<String> wrongPredictions = new TreeSet<>(); for (String id : gold.keySet()) { int goldLabel = gold.get(id); int predictedLabel = predictions.get(id); if (goldLabel == predictedLabel) { correctPredictions.add(id); } else { wrongPredictions.add(id); } } return ((double) correctPredictions.size()) / ((double) correctPredictions.size() + wrongPredictions.size()); }  static Map<String, Integer> readLabelsFromFile(File file); static double computeAccuracy(Map<String, Integer> gold,
            Map<String, Integer> predictions); static void main(String[] args);  }### Answer:
@Test public void computeAccuracy() throws Exception { Map<String, Integer> gold = Scorer .readLabelsFromFile(getFileFromResources("test-gold1.txt")); Map<String, Integer> predictions1 = Scorer .readLabelsFromFile(getFileFromResources("test-predictions1.txt")); assertEquals(0.6, Scorer.computeAccuracy(gold, predictions1), 0.01); Map<String, Integer> predictions2 = Scorer .readLabelsFromFile(getFileFromResources("test-predictions2.txt")); assertEquals(1.0, Scorer.computeAccuracy(gold, predictions2), 0.01); Map<String, Integer> predictions3 = Scorer .readLabelsFromFile(getFileFromResources("test-predictions3.txt")); assertEquals(0.0, Scorer.computeAccuracy(gold, predictions3), 0.01); }