Skip to content

Instantly share code, notes, and snippets.

@mkamilov
Created February 6, 2018 09:43
Show Gist options
  • Save mkamilov/50a0c7a1d77191188d1b0477d1867f41 to your computer and use it in GitHub Desktop.
Save mkamilov/50a0c7a1d77191188d1b0477d1867f41 to your computer and use it in GitHub Desktop.
spam counter
#!/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