def loadSample(compfname): fnames = compfname.split(":") assert len(fnames) == 2 left = gopen(fnames[0]) right = gopen(fnames[1]) sample = [] for a, b in zip(left, right): sample.append((a.split(), b.split())) return sample
def loadSample(compfname): fnames = compfname.split(':') assert len(fnames) == 2 left = gopen(fnames[0]) right = gopen(fnames[1]) sample = [] for a, b in zip(left, right): sample.append((a.split(), b.split())) return sample
def main(options, args): model = SequiturTool.procureModel(options, loadSample) if options.applySample: lines = gopen(options.applySample).readlines() words = Set([word for line in lines for word in line.split()]) addUnknowns(model, words) translator = Translator(model) for line in lines: left = tuple(line.split()) try: result = translator(left) print(" ".join(result)) except translator.TranslationFailure: print("<translation-failed/>")
def main(options, args): model = SequiturTool.procureModel(options, loadSample) if options.applySample: lines = gopen(options.applySample).readlines() words = Set([ word for line in lines for word in line.split() ]) addUnknowns(model, words) translator = Translator(model) for line in lines: left = tuple(line.split()) try: result = translator(left) print ' '.join(result) except translator.TranslationFailure: print '<translation-failed/>'