def usage(): print 'Usage: tongwen.py [-s2t] inputfile' exit(0) def dbpath(): import os.path, sys if __name__ == '__main__': filename = sys.argv[0] else: filename = __file__ return os.path.abspath(os.path.dirname(filename)) if len(sys.argv) < 2: usage() s2t = mcache(dbpath()+'/s2t.db') t2s = mcache(dbpath()+'/t2s.db') s2tp = mcache(dbpath()+'/s2t_p.db') t2sp = mcache(dbpath()+'/t2s_p.db') tb1 = s2t tb2 = s2tp inputf = sys.argv[1] if inputf == '-t2s': if len(sys.argv) < 3: usage() else: tb1 = t2s tb2 = t2sp inputf = sys.argv[2]
#!/usr/bin/env python from mcache import * from s2t import * from s2t_phrase import * s2t_db = mcache('s2t.db') t2s_db = mcache('t2s.db') s2tp_db = mcache('s2t_p.db') t2sp_db = mcache('t2s_p.db') for k,v in s_2_t.iteritems(): s2t_db.addu(k,v) for k,v in t_2_s.iteritems(): t2s_db.addu(k,v) for k,v in s_2_t_phrase.iteritems(): s2tp_db.addu(k,v) for k,v in t_2_s_phrase.iteritems(): t2sp_db.addu(k,v)