graykode

(fixed) type of gold.target change from list to str

...@@ -466,7 +466,7 @@ def main(): ...@@ -466,7 +466,7 @@ def main():
466 for ref,gold in zip(p,eval_examples): 466 for ref,gold in zip(p,eval_examples):
467 predictions.append(str(gold.idx)+'\t'+ref) 467 predictions.append(str(gold.idx)+'\t'+ref)
468 f.write(str(gold.idx)+'\t'+ref+'\n') 468 f.write(str(gold.idx)+'\t'+ref+'\n')
469 - f1.write(str(gold.idx)+'\t'+gold.target+'\n') 469 + f1.write(str(gold.idx)+'\t'+' '.join(gold.target)+'\n')
470 470
471 (goldMap, predictionMap) = bleu.computeMaps(predictions, os.path.join(args.output_dir, "dev.gold")) 471 (goldMap, predictionMap) = bleu.computeMaps(predictions, os.path.join(args.output_dir, "dev.gold"))
472 dev_bleu=round(bleu.bleuFromMaps(goldMap, predictionMap)[0],2) 472 dev_bleu=round(bleu.bleuFromMaps(goldMap, predictionMap)[0],2)
...@@ -523,7 +523,7 @@ def main(): ...@@ -523,7 +523,7 @@ def main():
523 for ref,gold in zip(p,eval_examples): 523 for ref,gold in zip(p,eval_examples):
524 predictions.append(str(gold.idx)+'\t'+ref) 524 predictions.append(str(gold.idx)+'\t'+ref)
525 f.write(str(gold.idx)+'\t'+ref+'\n') 525 f.write(str(gold.idx)+'\t'+ref+'\n')
526 - f1.write(str(gold.idx)+'\t'+gold.target+'\n') 526 + f1.write(str(gold.idx)+'\t'+' '.join(gold.target)+'\n')
527 527
528 (goldMap, predictionMap) = bleu.computeMaps(predictions, os.path.join(args.output_dir, "test_{}.gold".format(idx))) 528 (goldMap, predictionMap) = bleu.computeMaps(predictions, os.path.join(args.output_dir, "test_{}.gold".format(idx)))
529 dev_bleu=round(bleu.bleuFromMaps(goldMap, predictionMap)[0],2) 529 dev_bleu=round(bleu.bleuFromMaps(goldMap, predictionMap)[0],2)
......