Example #1
0
def adnewsfilterM(datelist):
    for tocom in datelist:
        today = tocom
        
        sentlist=[]
        fb= open(rawpath+r'DATA/step8_mR/'+str(today)+r'b', 'w')
        ff= open(rawpath+r'DATA/step8_mR/'+str(today)+r'f', 'w')
        for item in open(rawpath+r'DATA/step8_mR/'+str(today), '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
Example #2
0
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
Example #3
0
                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
        ltom1=rawpath+r'DATA/step8_mwordsegfilter/'+str(today)+'list'