brevityPenalty static method

double brevityPenalty(
  1. int closestRef,
  2. int hypLength
)

Brevity penalty: penalizes hypotheses shorter than references.

Implementation

static double brevityPenalty(int closestRef, int hypLength) {
  if (hypLength <= 0) return 0.0;
  if (closestRef <= 0 || hypLength > closestRef) return 1.0;
  return math.exp(1.0 - closestRef / hypLength);
}