Ejemplo n.º 1
0
    def ask_grandpy(self, message):
        """Parse and clean the question sent by the user to grandpy
            
        message : string object"""

        grandpy_information = dict()
        parser = Parser()

        #Clean the message
        message = parser.clean_message(message)
        message = parser.parse_message(message)

        #Getting coordinates of location from Google Maps API
        maps = Maps(message)
        coordinates = maps.get_coordinates_from_locations()

        if "error_message" in coordinates.keys():
            return {"error_message" : self.error_message()}

        else:
            grandpy_information.update({"coordinates" : coordinates})

            #Getting information from Wikipedia Page
            wiki = Wikipedia(coordinates)
            wiki.get_pageid_from_coordinates()
            wiki.get_content_from_pageid()   
            grandpy_information.update({"content" : wiki.content})

            return grandpy_information
Ejemplo n.º 2
0
def test_clean_message():
    """Test the method clean_message from the class Parser"""

    message_to_test = "Je--voudrais\\connaître les Informations sur Parïs+Marseille-Caen."
    parser_to_test = Parser()
    message_to_test = parser_to_test.clean_message(message_to_test)
    final_message = "je voudrais connaitre les informations sur paris marseille caen"
    assert message_to_test == final_message