Created
February 6, 2018 09:43
-
-
Save mkamilov/50a0c7a1d77191188d1b0477d1867f41 to your computer and use it in GitHub Desktop.
spam counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
class Filter: | |
spamWords = ["bad", "giveaway"] | |
def __init__(self): | |
pass | |
def getSpamWordsCount(self, userId, post): | |
count = 0 | |
for s in self.spamWords: | |
count += post.count(s); | |
return count | |
def addSpamWord(self, spam): | |
self.spamWords.append(spam); | |
f = Filter() | |
print f.getSpamWordsCount(1, "this is bad bad tweet with giveaway info") | |
print f.getSpamWordsCount(1, "earn some money") | |
f.addSpamWord("earn"); | |
print f.getSpamWordsCount(1, "this is tweet about earnings") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment