def adnewsfilterT(datelist,loclist): #today = datetime.date.today() #today = '2012-04-21' for tocom in datelist: today = tocom for location in loclist: print location sentlist=[] fb= open(rawpath+r'DATA/step7_wordsegfilter/'+str(today)+r'/'+location+r'b', 'w') ff= open(rawpath+r'DATA/step7_wordsegfilter/'+str(today)+r'/'+location+r'f', 'w') for item in open(rawpath+r'DATA/step7_wordsegfilter/'+str(today)+r'/'+location, 'r'): text = item try: print text sentlist.append(text) except IOError,e: print "Something is wrong: %s" % e pass cl2=step3_adnewsfilter.naivebayes(step3_adnewsfilter.getwords) step3_adnewsfilter.sampletrain(cl2,filenameing,filenameinb) for sent in sentlist: try:#print cl2.classify(sent) fb.write(cl2.classify(sent)+'\n') except IOError,e: print "Something is wrong: %s" % e pass cl2=step3_adnewsfilter.fisherclassifier(step3_adnewsfilter.getwords) step3_adnewsfilter.sampletrain(cl2,filenameing,filenameinb) for sent in sentlist: try: #print cl2.classify(sent) ff.write(cl2.classify(sent)+'\n') except IOError,e: print "Something is wrong: %s" % e pass
print text sentlist.append(text) except IOError,e: print "Something is wrong: %s" % e pass cl2=step3_adnewsfilter.naivebayes(step3_adnewsfilter.getwords) step3_adnewsfilter.sampletrain(cl2,filenameing,filenameinb) for sent in sentlist: try:#print cl2.classify(sent) fb.write(cl2.classify(sent)+'\n') except IOError,e: print "Something is wrong: %s" % e pass cl2=step3_adnewsfilter.fisherclassifier(step3_adnewsfilter.getwords) step3_adnewsfilter.sampletrain(cl2,filenameing,filenameinb) for sent in sentlist: try: #print cl2.classify(sent) ff.write(cl2.classify(sent)+'\n') except IOError,e: print "Something is wrong: %s" % e pass fb.close() ff.close() def listtoMdb(db): for tocom in datelist: today = tocom