anonymous
  • anonymous
In the solution for PS5 (the newsfeed problem), the last problem -- user-specified triggers -- the solution uses a function 'makeTrigger' which modifies a trigger_map dict. Then, in the readTriggerConfig function, a makeTrigger call is assigned to a variable 'trigger'... but then, I noticed that 'trigger' is not used again. Is this just a construct to allow makeTrigger to be called.. or is there another way to do, without creating extra variables?
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
you don't need an extra class makeTrigger. Here are all my classes: class NewsStory: """description of class""" def __init__(self, guid, title, subject, summary, link): self.guid = guid self.title = title self.subject = subject self.summary = summary self.link = link def get_guid(self): return self.guid def get_title(self): return self.title def get_subject(self): return self.subject def get_summary(self): return self.summary def get_link(self): return self.link class Trigger(object): def evaluate(self, story): """ Returns True if an alert should be generated for the given news item, or False otherwise. """ raise NotImplementedError class WordTrigger(Trigger): def __init__(self,word): self.word = word.lower() def is_word_in(self,text): if self.word in text: return True else: return False def noPunct(text): intab = string.punctuation outtab = " "*32 trantab = maketrans(intab, outtab) return text.translate(trantab) class NotTrigger(Trigger): def __init__(self,obj): self.obj = obj def evaluate(self,obj): return not self.obj.evaluate(self) class AndTrigger(Trigger): def __init__(self,object1,object2): self.object1 = object1 self.object2 = object2 def evaluate(self,obj): return self.object1.evaluate(obj) and self.object2.evaluate(obj) class OrTrigger(Trigger): def __init__(self,object1,object2): self.object1 = object1 self.object2 = object2 def evaluate(self,obj): return self.object1.evaluate(obj) or self.object2.evaluate(obj) class PhraseTrigger(Trigger): def __init__(self,phrase): self.phrase = phrase def is_phrase_in(self,text): if self.phrase in text: return True else: return False def evaluate(self,object): #objects subject, title, or summary text = object.get_subject() + object.get_title() + object.get_summary() text = noPunct(text) #text = text.split() return self.is_phrase_in(text) class TitleTrigger(WordTrigger): def evaluate(self,object): text = noPunct(object.get_title().lower()) text = text.split() return self.is_word_in(text) class SubjectTrigger(WordTrigger): def evaluate(self,object): text = noPunct(object.get_subject().lower()) text = text.split() return self.is_word_in(text) class SummaryTrigger(WordTrigger): def evaluate(self,object): text = noPunct(object.get_summary().lower()) text = text.split() return self.is_word_in(text)

Looking for something else?

Not the answer you are looking for? Search for more explanations.