#!/usr/bin/env python import cPickle from sys import argv if len(argv) == 2: print "Converts from the cfz 0.6.0 db format to >= 0.8.0 format.\nUsage: convertdb infile.db outfile.db\nBy default these are clean.db and nasty.db" else: if len(argv) == 3: infile = argv[1] outfile = argv[2] else: infile = "clean.db" outfile = "nasty.db" wordfile=open(infile,"r") sentances=cPickle.load(wordfile) sentstruc=cPickle.load(wordfile) del cPickle wordfile.close() f = open(outfile, "w") f.write("$sentences\n") x = 0 while x < len(sentstruc): y = 0 while y < len(sentstruc[x]): f.write(sentstruc[x][y]) f.write(" ") y = y+1 x = x+1 f.write("\n") x = 0 y = sentances.keys() while x < len(y): f.write("$") f.write(y[x]) f.write("\n") a = 0 while a < len(sentances[y[x]]): f.write(sentances[y[x]][a]) f.write("\n") a = a + 1 x = x+1 f.close