Пример #1
0
    def response(self):
        """
        Function to return the the response bases on the query.

        This function checks the query passed in by the user, and returns the
        response from the appopriate query. The query should have already been
        passed in when creating the "InferenceNetwork" object.
        ----------
        self    : none

        Returns
        -------
        response  : string
            The appropriate response to the user's input query
        """
        if self.node_type == "info":
            node = InfoNode()
        else:
            # Check if query is NBA related
            flag = isNBA(self.query)
            if flag == 0:
                return unsure
            elif flag == -1:
                return non_nba

            # Query is definitely NBA related
            if self.node_type == "rank":
                node = RankNode()

            if self.node_type == "stat":
                node = StatNode()

        node.load_query(self.query)
        return node.response()
Пример #2
0
    def test_response(self):
        node = InfoNode()
        test_verbs = ["be", "do", "build", "make", "Cannot Understand"]

        for verb in test_verbs:
            node.load_query(verb)
            resp = node.response()
            self.assertIsInstance(
                resp, str,
                "response test failed at verb: {}. Got instance of {}, expected instance of str"
                .format(verb, type(resp)))
Пример #3
0
    def response(self):
        if self.node_type == "info":
            node = InfoNode()
        else:
            # Check if query is NBA related
            flag = isNBA(self.query)
            if flag == 0:
                return unsure
            elif flag == -1:
                return non_nba

            # Query is definitely NBA related
            if self.node_type == "rank":
                node = RankNode()

            if self.node_type == "stat":
                node = StatNode()

        node.load_query(self.query)
        return node.response()