a = Alignment(a) finally: output_filename = '%s/%s-%s.my' % (args.folder, args.lang1, args.lang2) if not a: raise SystemExit with open(output_filename, 'w') as f: for i, j, c in a.data: f.write("%d\t%d\t%.2f\n" % (i, j, c)) print >> sys.stderr, "Wrote alignment to %s." % output_filename c = a.summed_cost() print >> sys.stderr, "Total cost", c, "avg", c/len(a.data) if args.plot: import plot plot.plot_cost_matrix(cost, a.as_ladder(), plot_filename=args.plot) if args.plot_sim: import plot c = [[0 for s2 in t2] for s1 in t1] _i, _j = 0, 0 for i, j, _ in forced_rungs + [(len(t1), len(t2), 0)]: for mi in range(_i, i): for mj in range(_j, j): c[mi][mj] = calculate_cost([t1[mi]], [t2[mj]]) _i, _j = i, j # a2 = Alignment.from_file('/tmp/pl-cu.new') plot.plot_cost_matrix(c, path=a.as_ladder(with_costs=True),