How to use the textworld.utils.uniquify function in textworld

To help you get started, we’ve selected a few textworld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / TextWorld / textworld / generator / dependency_tree.py View on Github external
def _update(self) -> None:
        self._leaves_values = []
        self._leaves_elements = []

        for node in self:
            if len(node.children) == 0:
                self._leaves_elements.append(node.element)
                self._leaves_values.append(node.element.value)

        self._leaves_values = uniquify(self._leaves_values)
        self._leaves_elements = uniquify(self._leaves_elements)
github microsoft / TextWorld / textworld / generator / dependency_tree.py View on Github external
def _update(self) -> None:
        self._leaves_values = []
        self._leaves_elements = []

        for node in self:
            if len(node.children) == 0:
                self._leaves_elements.append(node.element)
                self._leaves_values.append(node.element.value)

        self._leaves_values = uniquify(self._leaves_values)
        self._leaves_elements = uniquify(self._leaves_elements)
github microsoft / TextWorld / textworld / generator / text_grammar.py View on Github external
Parameters
        ----------
        type :
            Object type.

        Returns
        -------
        names :
            All possible names.
        """
        expansions = self.get_all_expansions_for_tag("#({})#".format(type))
        for room_type in self.grammar["#room_type#"].alternatives:
            expansions += self.get_all_expansions_for_tag("#{}_({})#".format(room_type.full_form(), type))

        return uniquify(expansions)
github microsoft / TextWorld / textworld / logic / __init__.py View on Github external
def variables(self):
        if not hasattr(self, "_variables"):
            self._variables = tuple(uniquify(var for prop in self.all_propositions for var in prop.arguments))

        return self._variables