Exemplo n.º 1
0
    def process_web_action_request(self, text, curr_url):
        """
        Parses the provided text into web text actions that will be converted into
        web actions by the web text to action mapper. The order will be maintained.
        :param text: the input command text
        :param curr_url: the url of the current web page
        :return: the action request response, which will be empty or None if in error
        """
        web_action_request = None
        if self.valid_web_jargon(text) and h.is_text_type(curr_url) and len(curr_url) > 0:
            # extract action request from the current command and add to web action token list
            words = text.split(" ")
            words = [x for x in words if len(x) > 0]
            curr_request = self.extract_action_request(text, words, curr_url)
            if curr_request is not None:
                web_action_request = curr_request
        else:
            h.log_to_console(["request error: ", text])

        return web_action_request
Exemplo n.º 2
0
 def POST(self):
     try:
         # parse out json request with text command and current page URL
         request = web.data()
         request_dict = json.loads(request)
         log_to_console(['received request: ', request])
         # extract the web actions from the given command and return a browser action response
         resp = extract_web_actions(request_dict, self.processor, self.mapper)
         log_to_console(['sending response: ', resp])
         return resp
     except ValueError:
         log_to_console(["could not process Web Jargon request..."])
     return err_msg