def _get_candidates()

in gym_wikinav/envs/wikinav_env/web_graph.py [0:0]


    def _get_candidates(self):
        """
        Build a beam of candidate next-page IDs consisting of available links
        on the current article.

        NB: The candidate list returned may have a regular pattern, e.g. the
        stop sentinel / filler candidates (for candidate lists which are smaller
        than the beam size) may always be in the same position in the list.
        Make sure to not build models (e.g. ones with output biases) that might
        capitalize on this pattern.

        Returns:
            candidates: List of article IDs of length `self.beam_size`.
        """
        all_links = self.graph.get_article_links(self.cur_article_id)

        # Sample `beam_size - 1`; add the STOP sentinel
        candidates = random.sample(all_links, min(self.beam_size - 1,
                                                  len(all_links)))
        candidates.append(self.graph.stop_sentinel)

        if len(candidates) < self.beam_size:
            padding = [self._dummy_page] * (self.beam_size - len(candidates))
            candidates.extend(padding)

        return candidates