Esempio n. 1
0
 def get_search_query(self, spoken_text):
     '''
     Parse spoken text to retrieve a the name of the routine.
     '''
     search_terms = ['to', 'for']
     search_query = get_search_query(spoken_text, self.patterns,
                                     search_terms)
     return search_query
Esempio n. 2
0
 def get_recipient(self, spoken_text):
     '''Returns the recipient's name from spoken text.'''
     search_terms = ['to']
     recipient = get_search_query(
         spoken_text,
         self.patterns,
         search_terms
     )
     return recipient
    def test_false_search_indicators(self):
        patterns = [
            'send an email',
            'send an email to',
            'google search',
            'show me on google',
        ]
        search_terms = ['to', 'on']
        false_search_term_indicators = ['want', 'like']
        spoken_text1 = 'I want to send an email to Alex'
        spoken_text2 = 'I would like to do a google search on Python'

        response1 = feature_helpers.get_search_query(
            spoken_text1, patterns, search_terms, false_search_term_indicators)
        response2 = feature_helpers.get_search_query(
            spoken_text2, patterns, search_terms, false_search_term_indicators)

        self.assertEqual(response1, 'Alex')
        self.assertEqual(response2, 'Python')
Esempio n. 4
0
 def get_search_query(self, spoken_text, patterns):
     '''
     Parses spoken text to retrieve a search query for Youtube
     Argument: <list> spoken_text (tokenized. i.e. list of words), OR
             <str> spoken_text (not tokenized),
     <list> patterns
     Return type: <string> query
     '''
     search_terms = ['about', 'on', 'for', 'search']
     query = get_search_query(spoken_text, patterns, search_terms)
     return query
Esempio n. 5
0
 def get_search_query(self, spoken_text, patterns):
     '''
     Parses spoken text to retrieve a search query for Wikipedia
     Argument: <string> spoken_text (tokenized. i.e. list of words), OR
             <str> spoken_text (not tokenized),
             <list> patterns
     Return type: <string> spoken_text (this is actually the search query
     as retrieved from spoken_text.
     '''
     search_terms = ['about', 'on', 'for', 'search']
     query = get_search_query(spoken_text, patterns, search_terms)
     return query
    def test_get_search_query(self):
        patterns = [
            'send an email', 'send an email to', 'google search',
            'show me on google', "wikipedia", "search wikipedia for",
            "look up on wikipedia"
        ]
        search_terms = ['to', 'on', 'for', 'search']
        false_search_term_indicators = ['want', 'like']
        spoken_text1 = 'send an email to Alex'
        spoken_text2 = 'Do a google search on Python'
        spoken_text3 = 'search wikipedia for my query'

        response1 = feature_helpers.get_search_query(
            spoken_text1, patterns, search_terms, false_search_term_indicators)
        response2 = feature_helpers.get_search_query(
            spoken_text2, patterns, search_terms, false_search_term_indicators)
        response3 = feature_helpers.get_search_query(
            spoken_text3, patterns, search_terms, false_search_term_indicators)

        self.assertEqual(response1, 'Alex')
        self.assertEqual(response2, 'Python')
        self.assertEqual(response3, 'my query')
Esempio n. 7
0
 def get_search_query(self, spoken_text):
     '''
     Parse spoken text to retrieve a search query for Zoom.
     e.g. spoken_text: I would like to go to french class
     query = french class
     '''
     search_terms = ['to', 'for']
     search_query = get_search_query(
         spoken_text,
         self.patterns,
         search_terms
     )
     return search_query
    def test_no_search_query_given(self):
        patterns = [
            'send an email',
            'send an email to',
            'google search',
            'show me on google',
        ]
        search_terms = ['to', 'on']
        false_search_term_indicators = ['want', 'like']
        spoken_text1 = 'I want to send an email to'
        spoken_text2 = 'I would like to do a google search on'
        spoken_text3 = 'send an email'

        response1 = feature_helpers.get_search_query(
            spoken_text1, patterns, search_terms, false_search_term_indicators)
        response2 = feature_helpers.get_search_query(
            spoken_text2, patterns, search_terms, false_search_term_indicators)
        response3 = feature_helpers.get_search_query(
            spoken_text3, patterns, search_terms, false_search_term_indicators)

        self.assertEqual(response1, "")
        self.assertEqual(response2, "")
        self.assertEqual(response3, "")