code: public List<CcgParse> decodeBestParsesForSpan(int spanStart, int spanEnd, int numParses,
        CcgParser parser) {
      // Perform a heap sort on the array indexes paired with the
      // probabilities.
      double[] probs = probabilities[spanStart][spanEnd];
      double[] probabilityHeap = new double[probs.length];
      Integer[] chartEntryIndexes = new Integer[probabilities[spanStart][spanEnd].length];
      int numChartEntries = getNumChartEntriesForSpan(spanStart, spanEnd);
      int heapSize = 0;
  
      for (int i = 0; i < numChartEntries; i++) {
        HeapUtils.offer(chartEntryIndexes, probabilityHeap, heapSize, i, probs[i]);
        heapSize++;
      }
  
      // Heaps are min-heaps, so we throw away the initial entries.
      // Then the remaining entries are the best parses.
      List<CcgParse> bestParses = Lists.newArrayList();
      
      while (heapSize > 0) {
        if (heapSize <= numParses) {
          bestParses.add(decodeParseFromSpan(spanStart, spanEnd, chartEntryIndexes[0], parser));
        }
  
        HeapUtils.removeMin(chartEntryIndexes, probabilityHeap, heapSize);
        heapSize--;
      }
  
      Collections.reverse(bestParses);
      return bestParses;
    }
docs: Gets the {@code numParses} best CCG parses spanning
  {@code spanStart} to {@code spanEnd}.
  
  @param spanStart
  @param spanEnd
  @param numParses
  @param parser
  @return