Example #1
0
 def test_match_6(self):
     matcher = KMP(
         "alksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsaf"
     )
     self.assertTrue(
         matcher.match(
             "09012102412sdjadalksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsafm,zxcoqwo90e12ne12e"
         ))
Example #2
0
def evaluateKMP():
	if (request.is_json):
		content = request.get_json()
		# construct string matcher
		pattern = content['spamkey']
		matcher = KMP(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"
Example #3
0
 def test_match_7(self):
     matcher = KMP("SINGLES AROUND YOU")
     self.assertTrue(matcher.match("CHECK THIS OUT! SINGLES AROUND YOU!!"))
Example #4
0
 def test_border_1(self):
     matcher = KMP("AAAA")
     self.assertEqual(matcher.get_border_table(), [0, 1, 2, 3])
Example #5
0
 def test_match_5(self):
     matcher = KMP("checking it out")
     self.assertTrue(
         matcher.match("hello world! please consider checking it out!"))
Example #6
0
 def test_match_4(self):
     matcher = KMP("bcgl")
     self.assertFalse(matcher.match("abcbcgdbclgx"))
Example #7
0
 def test_match_3(self):
     matcher = KMP("bcgl")
     self.assertTrue(matcher.match("abcbcglx"))
Example #8
0
 def test_match_2(self):
     matcher = KMP("abcaby")
     self.assertTrue(matcher.match("abxabcabcaby"))
Example #9
0
 def test_match_1(self):
     matcher = KMP("abc")
     self.assertTrue(matcher.match("abcdef"))
Example #10
0
 def test_border_8(self):
     matcher = KMP("abcaby")
     self.assertEqual(matcher.get_border_table(), [0, 0, 0, 1, 2, 0])
Example #11
0
 def test_border_7(self):
     matcher = KMP("acacabacacabacacac")
     self.assertEqual(
         matcher.get_border_table(),
         [0, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4])
Example #12
0
 def test_border_6(self):
     matcher = KMP("AABAABAAA")
     self.assertEqual(matcher.get_border_table(),
                      [0, 1, 0, 1, 2, 3, 4, 5, 2])
Example #13
0
 def test_border_4(self):
     matcher = KMP("AAACAAAAAC")
     self.assertEqual(matcher.get_border_table(),
                      [0, 1, 2, 0, 1, 2, 3, 3, 3, 4])
Example #14
0
 def test_border_2(self):
     matcher = KMP("ABCDE")
     self.assertEqual(matcher.get_border_table(), [0, 0, 0, 0, 0])