def test_match_5(self): matcher = BoyerMoore( "alksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsaf" ) # a : 4, b : 5, c:3 self.assertTrue( matcher.match( "09012102412sdjadalksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsafm" ))
def evaluateBM(): if (request.is_json): content = request.get_json() # construct string matcher pattern = content['spamkey'] matcher = BoyerMoore(pattern) # get tweets based on search key tweets = api.search_tweets(content['searchkey']) # Evaluate tweets using matcher for tweet in tweets: tweet['is_spam'] = matcher.match(tweet['text'].lower()) return json.dumps(tweets); else: return "Bad Request"
def test_match_4(self): matcher = BoyerMoore("baku") # a : 4, b : 5, c:3 self.assertTrue( matcher.match("kami menggunakan kata yang terlalu baku sehingga"))
def test_match_3(self): matcher = BoyerMoore("rithm") # a : 4, b : 5, c:3 self.assertFalse(matcher.match("the rythm is so effin good"))
def test_match_2(self): matcher = BoyerMoore("rithm") # a : 4, b : 5, c:3 self.assertTrue(matcher.match("a pattern matching algorithm"))
def test_match_1(self): matcher = BoyerMoore("abacab") # a : 4, b : 5, c:3 self.assertTrue(matcher.match("abacaabadcabacabaabb"))