Exemplo n.º 1
0
    def is_literal_identified(self, literal: Literal):
        """
        Is the given simple literal identified yet?

        :param literal: the literal's data.
        :return: the identification status.
        """
        return literal.as_tuple() in self.identified_literals
Exemplo n.º 2
0
    def get_literal_number(self, literal: Literal):
        """
        Get the number of an already-identified simple literal.

        :param literal: the literal's data.
        :return: the literal's identifier.
        """
        return self.identified_literals[literal.as_tuple()]
Exemplo n.º 3
0
    def register_literal(self, literal: Literal) -> int:
        """
        Add a new association for a given simple literal.

        :param literal: the literal's data.
        :return: the new identification number for the literal.
        """

        old_number = self._current_number
        self.identified_literals[literal.as_tuple()] = self._current_number
        self.reverse_identified_literals[self._current_number] = literal
        self._current_number += 1
        return old_number