Пример #1
0
 def test_match_6(self):
     matcher = KMP(
         "alksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsaf"
     )
     self.assertTrue(
         matcher.match(
             "09012102412sdjadalksjflkasjflkasjfaslfjlasjflajsflajsflasjflasjflkasjflkasjflkasjflkjsafm,zxcoqwo90e12ne12e"
         ))
Пример #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"
Пример #3
0
 def test_match_7(self):
     matcher = KMP("SINGLES AROUND YOU")
     self.assertTrue(matcher.match("CHECK THIS OUT! SINGLES AROUND YOU!!"))
Пример #4
0
 def test_border_1(self):
     matcher = KMP("AAAA")
     self.assertEqual(matcher.get_border_table(), [0, 1, 2, 3])
Пример #5
0
 def test_match_5(self):
     matcher = KMP("checking it out")
     self.assertTrue(
         matcher.match("hello world! please consider checking it out!"))
Пример #6
0
 def test_match_4(self):
     matcher = KMP("bcgl")
     self.assertFalse(matcher.match("abcbcgdbclgx"))
Пример #7
0
 def test_match_3(self):
     matcher = KMP("bcgl")
     self.assertTrue(matcher.match("abcbcglx"))
Пример #8
0
 def test_match_2(self):
     matcher = KMP("abcaby")
     self.assertTrue(matcher.match("abxabcabcaby"))
Пример #9
0
 def test_match_1(self):
     matcher = KMP("abc")
     self.assertTrue(matcher.match("abcdef"))
Пример #10
0
 def test_border_8(self):
     matcher = KMP("abcaby")
     self.assertEqual(matcher.get_border_table(), [0, 0, 0, 1, 2, 0])
Пример #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])
Пример #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])
Пример #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])
Пример #14
0
 def test_border_2(self):
     matcher = KMP("ABCDE")
     self.assertEqual(matcher.get_border_table(), [0, 0, 0, 0, 0])