Ejemplo n.º 1
0
                        print "%d ||| %s ||| %.4lf" % (i, tr, sc)

                else:
                    print tree
                parseval_time -= time.time()            
                all_pp += pp
                parseval_time += time.time()

                n, e = forest.size()
    ##            print >> logs, "sent #%d %s, %d words, %d nodes, %d edges, decoded in %.2lf secs" % \
    ##                  (i+1, forest.tag, len(forest), n, e, this_time)

    ##            print score, "\t", tree, "\n", fvector
                if opts.verbose:
                    print >> logs, "bleu+1=%.4lf" % pp.score()
                if opts.debug:
                    print >> logs, score, "\t", tree #, "\n", fvector

                sum_score += score            
            

    print >> logs, "overall: %d sents. decode time in %.2lf secs (avg %.2lf secs per sent)" % \
          (i+1, decoder.decode_time, decoder.decode_time / (i+1))
    print >> logs, "overall: %d sents. parseval time in %.2lf secs (avg %.2lf secs per sent)" % \
          (i+1, parseval_time, parseval_time / (i+1))
##    print >> logs, all_pp
    print >> logs, "overall bleu = %.4lf (%.2lf)" % all_pp.score_ratio() # overall bleu
    print >> logs, "overall model-cost: %.4lf" % sum_score

            
Ejemplo n.º 2
0
        rules = read_rules(opts.rules)
        if opts.extrarules:
            rules = read_rules(opts.extrarules, rules)

        if forestline.strip() == "": ## empty forest (pure byline)
            forestline = "(0<gt_prob:0> )"
        f = forest_from_text(forestline)
        

        # for bleu
        fbleu = Bleu(refs=reflines)

        srcline = srcline.split()
        if srcline[0] == foreign_sentence_tag:
            del srcline[0]
        srcline = " ".join(srcline)
        
        print f.dump(rules, \
                     i + opts.sentid, \
                     srcline, byline.strip(), reflines)
        sys.stderr.write("t=%s read line %s\n" % (monitor.cpu(), i+1))
        sys.stderr.flush()

        if i % 10 == 9:
            print >> logs,  "overall 1-best bleu = %.4lf (%.2lf) score = %.4lf" \
                  % (onebestbleus.score_ratio() + (sum(onebestscores)/(i+1),))
            for key in hopebleus:
                print >> logs,  "overall hope%s   bleu = %.4lf (%.2lf) score = %.4lf" \
                      % (key, hopebleus[key].score_ratio() + (sum(hopescores[key])/(i+1),))