mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-08-30 17:23:03 +08:00
repair bleu score computation (#14626)
This commit is contained in:
@@ -69,7 +69,7 @@ PostProcess:
|
||||
Metric:
|
||||
name: LaTeXOCRMetric
|
||||
main_indicator: exp_rate
|
||||
cal_bleu_score: False
|
||||
cal_bleu_score: True
|
||||
|
||||
Train:
|
||||
dataset:
|
||||
|
||||
@@ -53,7 +53,7 @@ Architecture:
|
||||
encoder_hidden_size: 2048
|
||||
is_export: False
|
||||
length_aware: True
|
||||
use_parallel: True,
|
||||
use_parallel: True
|
||||
parallel_step: 3
|
||||
|
||||
Loss:
|
||||
@@ -67,7 +67,7 @@ PostProcess:
|
||||
Metric:
|
||||
name: LaTeXOCRMetric
|
||||
main_indicator: exp_rate
|
||||
cal_bleu_score: False
|
||||
cal_bleu_score: True
|
||||
|
||||
Train:
|
||||
dataset:
|
||||
|
||||
@@ -66,7 +66,7 @@ PostProcess:
|
||||
Metric:
|
||||
name: LaTeXOCRMetric
|
||||
main_indicator: exp_rate
|
||||
cal_bleu_score: False
|
||||
cal_bleu_score: True
|
||||
|
||||
Train:
|
||||
dataset:
|
||||
|
||||
@@ -66,7 +66,7 @@ PostProcess:
|
||||
Metric:
|
||||
name: LaTeXOCRMetric
|
||||
main_indicator: exp_rate
|
||||
cal_bleu_score: False
|
||||
cal_bleu_score: True
|
||||
|
||||
Train:
|
||||
dataset:
|
||||
|
||||
@@ -98,7 +98,10 @@ def compute_bleu(reference_corpus, translation_corpus, max_order=4, smooth=False
|
||||
else:
|
||||
geo_mean = 0
|
||||
|
||||
ratio = float(translation_length) / reference_length
|
||||
if float(translation_length) == 0 or float(reference_length) == 0:
|
||||
ratio = 1e-5
|
||||
else:
|
||||
ratio = float(translation_length) / reference_length
|
||||
|
||||
if ratio > 1.0:
|
||||
bp = 1.0
|
||||
|
||||
Reference in New Issue
Block a user