(self, target_text, prediction_text)
return results
Calculates length scores in target_text and prediction_text.

    Args:
      target_text: target text that may contain lengths.
      prediction_text: prediction text that may contain lengths.

    Returns:
      A dict mapping each length type to a LengthScore object.
    Raises:
      ValueError: If an invalid length type is encountered.
Calculates length scores in target_text and prediction_text.
Calculates length scores in target_text and prediction_text .
def score(self, target_text, prediction_text) -> Dict[Text, LengthScore]:
    """Calculates length scores in target_text and prediction_text.

    Args:
      target_text: target text that may contain lengths.
      prediction_text: prediction text that may contain lengths.

    Returns:
      A dict mapping each length type to a LengthScore object.
    Raises:
      ValueError: If an invalid length type is encountered.
    """
    results = dict()
    for length_type in self._length_types:
      if length_type == "char":
        target_length = len(target_text)
        prediction_length = len(prediction_text)
      elif length_type == "word":
        target_length = len(self._tokenize(target_text))
        prediction_length = len(self._tokenize(prediction_text))

      relative_length = prediction_length / float(
          target_length) if target_length > 0 else 0.
      results[length_type] = LengthScore(target_length, prediction_length,
                                         relative_length)

      _update_length_counts(self._target_counts[length_type], target_length,
                            self._bin_sizes[length_type])
      _update_length_counts(self._prediction_counts[length_type],
                            prediction_length, self._bin_sizes[length_type])
      _update_length_counts(self._relative_counts[length_type], relative_length,
                            self._bin_sizes["relative"])
    return results
def score ( self , target_text , prediction_text ) -> Dict [ Text , LengthScore ] : results = dict ( ) for length_type in self . _length_types : if length_type == "char" : target_length = len ( target_text ) prediction_length = len ( prediction_text ) elif length_type == "word" : target_length = len ( self . _tokenize ( target_text ) ) prediction_length = len ( self . _tokenize ( prediction_text ) ) relative_length = prediction_length / float ( target_length ) if target_length > 0 else 0. results [ length_type ] = LengthScore ( target_length , prediction_length , relative_length ) _update_length_counts ( self . _target_counts [ length_type ] , target_length , self . _bin_sizes [ length_type ] ) _update_length_counts ( self . _prediction_counts [ length_type ] , prediction_length , self . _bin_sizes [ length_type ] ) _update_length_counts ( self . _relative_counts [ length_type ] , relative_length , self . _bin_sizes [ "relative" ] ) return results