@Override
  public void collectionProcessComplete(ProcessTrace arg0) throws ResourceProcessException,
          IOException {

    super.collectionProcessComplete(arg0);

    // TODO :: compute the cosine similarity measure
    // although it seems to be two nested for loops, the time complexity is only o(n).
    for (int index : queryIndexes) {
      HashMap<String, Integer> q = docs.get(index);
      ArrayList<Integer> ansList = answerIndexes.get(qIdList.get(index));
      for (int aIndex : ansList) {// for each answer index, get the answer doc.
        double element = computeCosineSimilarity(docs.get(index), docs.get(aIndex));
//        double element = computeDice(docs.get(index), docs.get(aIndex));

        sim.set(aIndex, element);
      }
    }

    // TODO :: compute the rank of retrieved sentences
    for (int index : queryIndexes) {
      ArrayList<Integer> ansList = answerIndexes.get(qIdList.get(index));
      HashMap<Integer, Double> simBuffer = new HashMap<Integer, Double>(ansList.size());
      for (int aIndex : ansList) {
        simBuffer.put(aIndex, sim.get(aIndex));
      }
      ArrayList<Entry<Integer, Double>> bufferList = new ArrayList<Entry<Integer, Double>>(
              simBuffer.entrySet());
      Collections.sort(bufferList, new Comparator<Entry<Integer, Double>>() {
        public int compare(Entry<Integer, Double> e1, Entry<Integer, Double> e2) {
          return e2.getValue().compareTo(e1.getValue());
        }
      });
      int i = 1;
      for (Entry<Integer, Double> entry : bufferList) {
        rank.set(entry.getKey(), i++);
      }
    }

    int previousQIndex = -1;
    for (int i = 0; i < docs.size(); i++) {
      if (relList.get(i) == 99)
        previousQIndex = i;
      if (relList.get(i) == 1) {
        System.out.println(String.format("Score: %.10f\trank=%d\t rel=%d\tqid=%d\tsent=%d",
                sim.get(i),rank.get(i),relList.get(i),qIdList.get(i),i-previousQIndex));
      }
    }
    // TODO :: compute the metric:: mean reciprocal rank
    double metric_mrr = compute_mrr();
    System.out.println(" (MRR) Mean Reciprocal Rank ::" + metric_mrr);

  }