Wednesday, December 28, 2011

Parse adaboost log file, get features

fh = open(r"c:\tmp\16_A7_Translation.log","r")

outf = open(r"c:\tmp\16_A7_Translation.features.txt", 'w')

igot = fh.readlines()

for line in igot:
        if line.find("best=") > -1:
                temp = line.split()
                ha = temp[1]
                about = ha.strip('best=')
                print about ## print to screen
                print >> outf, about ## print to file
print
outf.close()


#-----------------------
fh = open(r"c:\tmp\8_A7_Translation.log","r")

outf2 = open(r"c:\tmp\8_A7_Translation.features.txt", 'w')

igot = fh.readlines()

for line in igot:
        if line.find("best=") > -1:
                temp = line.split()
                ha = temp[1]
                about = ha.strip('best=')
                print about ## print to screen
                print >> outf2, about ## print to file
print
outf2.close()

No comments:

Post a Comment