Last active
October 12, 2015 19:18
-
-
Save saltavenger/4074927 to your computer and use it in GitHub Desktop.
trigger
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
# TODO: WordTrigger | |
class WordTrigger(Trigger): | |
def __init__(self, word): | |
self.word = word.lower() | |
def isWordIn(self, text): | |
newtext=[] | |
self.text = text.lower() | |
for c in string.punctuation: | |
self.text = self.text.replace(c, ' ').lower() | |
newText = self.text.split(' ') | |
return self.word in newText | |
# TODO: TitleTrigger | |
# TODO: SubjectTrigger | |
# TODO: SummaryTrigger | |
class TitleTrigger(WordTrigger): | |
def evaluate(self, story): | |
return self.isWordIn(story.getTitle()) | |
class SubjectTrigger(WordTrigger): | |
def evaluate(self, story): | |
return self.isWordIn(story.getSubject()) | |
class SummaryTrigger(WordTrigger): | |
def evaluate(self, story): | |
return self.isWordIn(story.getSummary()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment