Tuesday, January 3, 2012

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()

Monday, December 27, 2010

meaning of class FileInfo(UserDict)


from UserDict import UserDict

class FileInfo(UserDict): 1
1In Python, the ancestor of a class is simply listed in parentheses immediately after the class name. So the FileInfo class is inherited from the UserDict class