Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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/>")
Ejemplo n.º 4
0
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/>'