def execute(self): if "english" not in self.agent.blackboard: english = English() self.agent.stash("english",english) english = self.agent.fetch("english") tweets = self.agent.tweet_cache self.agent.tweet_cache = [] if self.filename != None: f = open(self.filename, "a") dayFiles = {} for tweet in tweets: if english.is_english(tweet["text"]): if self.filename != None: fOut = f else: dateName = "tweets-%i-%i-%i" % (tweet.created_at.year, tweet.created_at.month, tweet.created_at.day) if dateName not in dayFiles: dayFiles[dateName] = open(dateName, "a") fOut = dayFiles[dateName] self.write_tweet(fOut,tweet) if self.filename != None: f.close() for ff in dayFiles: ff.close()
def get(self): # self.response.write a = American() print a.print_out() e = English() print e.print_out() content = a.print_out() + e.print_out() self.response.write(a.print_out()) self.response.write(e.print_out())
def test_checkAmountCorrect(self): eng = English() #grenswaarde analyse correct = ["Correct", "Correct", "Correct", "Wrong", "Wrong"] #net goed/op grens alsoCorrect = ["Correct", "Correct", "Correct", "Correct", "Wrong"] #boven grens incorrect = ["Correct", "Correct", "Wrong", "Wrong", "Wrong"] #onder de grens self.assertEqual(eng.checkAmountCorrect(correct), True) self.assertEqual(eng.checkAmountCorrect(alsoCorrect), True) self.assertEqual(eng.checkAmountCorrect(incorrect), False)
def execute(self): if "english" not in self.agent.blackboard: english = English() self.agent.stash("english", english) english = self.agent.fetch("english") tweets = self.agent.tweet_cache self.agent.tweet_cache = [] for tweet in tweets: # Only dump English tweets. # XXX - Rest of world: remove this if statement if english.is_english(tweet["text"]): print tweet["text"]
def test_opt4Check(self, ): eng = English() self.assertEqual(eng.opt4Check("suppose"), "Correct") self.assertEqual(eng.opt4Check("supose"), "Wrong") self.assertEqual(eng.opt4Check("empty"), "Wrong")
def test_simplePresent(self): eng = English() self.assertEqual(eng.simplePresent('likes'), 'Correct') self.assertEqual(eng.simplePresent('incorrect'), 'Wrong') self.assertEqual(eng.simplePresent(''), 'Wrong')
def test_opt3Check(self, ): eng = English() self.assertEqual(eng.opt3Check("population"), "Correct") self.assertEqual(eng.opt3Check("poppulation"), "Wrong") self.assertEqual(eng.opt3Check("empty"), "Wrong")
def test_opt2Check(self, ): eng = English() self.assertEqual(eng.opt2Check("possible"), "Correct") self.assertEqual(eng.opt2Check("posible"), "Wrong") self.assertEqual(eng.opt2Check("empty"), "Wrong")
import requests, random from english import English from twitter import Twitter url = 'http://earthquake.usgs.gov/earthquakes/feed' \ '/v1.0/summary/significant_hour.geojson' test_url = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/significant_month.geojson' r = requests.get(url) if r.status_code == 200: if len(r.json()['features']) > 0: s = English(r.json()) t = Twitter() t.tweet(s.sentence()) else: print "Error: Status code {}".format(r.status_code)
def test_attCheck(self, ): eng = English() self.assertEqual(eng.attCheck("attended"), "Correct") #anything that is not ^ is wrong self.assertEqual(eng.attCheck("spread"), "Wrong") self.assertEqual(eng.attCheck(""), "Wrong")
def test_checkAllCorrect(self): eng = English() correct = ["Correct", "Correct", "Correct", "Correct", "Correct"] incorrect = ["Correct", "Correct", "Correct", "Correct", "Wrong"] self.assertEqual(eng.checkAllCorrect(correct), True) self.assertEqual(eng.checkAllCorrect(incorrect), False)
def english3(): return English().getView3(request)
def english2(): return English().getView2(request)
def english(): return English().getView1(request)
def test_opt5Check(self, ): eng = English() self.assertEqual(eng.opt5Check("tomorrow"), "Correct") self.assertEqual(eng.opt5Check("tomorow"), "Wrong") self.assertEqual(eng.opt5Check("empty"), "Wrong")
def test_govCheck(self, ): eng = English() self.assertEqual(eng.govCheck("government"), "Correct") #anything that is not ^ is wrong self.assertEqual(eng.govCheck("attended"), "Wrong") self.assertEqual(eng.govCheck(""), "Wrong")
def test_goingToFuture(self): eng = English() self.assertEqual(eng.goingToFuture('is going to phone'), 'Correct') self.assertEqual(eng.simplePresent('incorrect'), 'Wrong') self.assertEqual(eng.simplePresent(''), 'Wrong')
def test_busCheck(self, ): eng = English() self.assertEqual(eng.busCheck("business"), "Correct") #anything that is not ^ is wrong self.assertEqual(eng.busCheck("attended"), "Wrong") self.assertEqual(eng.busCheck(""), "Wrong")
def test_pastPerfect(self): eng = English() self.assertEqual(eng.pastPerfect('had eaten'), 'Correct') self.assertEqual(eng.simplePresent('incorrect'), 'Wrong') self.assertEqual(eng.simplePresent(''), 'Wrong')
def test_opt1Check(self): eng = English() self.assertEqual(eng.opt1Check("aspect"), "Correct") self.assertEqual(eng.opt1Check("asspect"), "Wrong") self.assertEqual(eng.opt1Check("empty"), "Wrong")