Example #1
0
def has_words(text, words_list):
    """
    Returns True if the given text contains and words in the given word list,
    otherwise returns False.
    """
    words = util.depunctuate(text, replacement=" ").split()
    words_list = [] if words_list is None else words_list
    num_found = [word for word in words if word.lower() in words_list]
    return len(num_found) != 0
Example #2
0
def has_words(text, words_list):
    """
    Returns True if the given text contains and words in the given word list,
    otherwise returns False.
    """
    words = util.depunctuate(text, replacement=" ").split()
    words_list = [] if words_list is None else words_list
    num_found = [word for word in words if word.lower() in words_list]
    return len(num_found) != 0
Example #3
0
 def test_depunctuate(self):
     s = "no, ...punctua.tion allowed?!"
     self.assertEqual(util.depunctuate(s), "no punctuation allowed")
     self.assertEqual(util.depunctuate(s, "!"), "no punctuation allowed!")
     self.assertEqual(util.depunctuate(s, "?", " "), "no     punctua tion allowed? ")