Example #1
0
 def encodefile(self, fromfile, tofile):
     assert self.filesupport
     ffrom = open(fromfile,'r')  
     fto = open(tofile,'w')
     for line in ffrom:
         a = intarraytobytearray( self.encodeseq( line.strip().split(' ') ))
         a.append(0) #delimiter
         a.append(1) #newline
         a.append(0) #delimiter
         a.tofile(fto)            
     fto.close()
     ffrom.close()
Example #2
0
 def encodefile(self, fromfile, tofile):
     """Encode a file, converting word tokens to class integers"""
     assert self.filesupport
     ffrom = open(fromfile, "r")
     fto = open(tofile, "w")
     for line in ffrom:
         a = intarraytobytearray(self.encodeseq(line.strip().split(" ")))
         a.append(0)  # delimiter
         a.append(1)  # newline
         a.append(0)  # delimiter
         a.tofile(fto)
     fto.close()
     ffrom.close()