def _prune(self):
        """Shorten hypotheses to the best k ones."""
        self.hypotheses = sorted(self.hypotheses,
                                 key=lambda e: e['probability'],
                                 reverse=True)[:self.k]
Shorten hypotheses to the best k ones.