(self, length_types: List[Text], bin_sizes=None)
Initializes a new LengthScorer.

    Valid repitition types that can be computed are:
      char: number of characters.
      word: number of words.

    Args:
      length_types: A list of length types to calculate.
      bin_sizes: bin_size of histograms. If None, char value of 10, word value
        of 5, and relative value of 0.1 are used.

    Returns:
      A dict mapping regs types to Score tuples.
Initializes a new LengthScorer.
Initializes a new LengthScorer .
def __init__(self, length_types: List[Text], bin_sizes=None):
    """Initializes a new LengthScorer.

    Valid repitition types that can be computed are:
      char: number of characters.
      word: number of words.

    Args:
      length_types: A list of length types to calculate.
      bin_sizes: bin_size of histograms. If None, char value of 10, word value
        of 5, and relative value of 0.1 are used.

    Returns:
      A dict mapping regs types to Score tuples.
    """
    self._tokenize = lambda s: s.split()
    self._length_types = length_types
    if not bin_sizes:
      self._bin_sizes = {"char": 20, "word": 5}
    else:
      self._bin_sizes = bin_sizes
    self._target_counts = {k: collections.Counter() for k in length_types}
    self._prediction_counts = {k: collections.Counter() for k in length_types}
    self._relative_counts = {k: collections.Counter() for k in length_types}

    for ltype in self._length_types:
      if ltype not in ["char", "word"]:
        raise ValueError("Type %s not supported." % ltype)
      if ltype not in self._bin_sizes:
        raise ValueError("Bin size for type %s need to be provided." % ltype)
      if self._bin_sizes[ltype] <= 0:
        raise ValueError("Bin size %d need to be positive." %
                         self._bin_sizes[ltype])
    if "relative" not in self._bin_sizes:
      self._bin_sizes["relative"] = 0.1
def __init__ ( self , length_types : List [ Text ] , bin_sizes = None ) : self . _tokenize = lambda s : s . split ( ) self . _length_types = length_types if not bin_sizes : self . _bin_sizes = { "char" : 20 , "word" : 5 } else : self . _bin_sizes = bin_sizes self . _target_counts = { k : collections . Counter ( ) for k in length_types } self . _prediction_counts = { k : collections . Counter ( ) for k in length_types } self . _relative_counts = { k : collections . Counter ( ) for k in length_types } for ltype in self . _length_types : if ltype not in [ "char" , "word" ] : raise ValueError ( "Type %s not supported." % ltype ) if ltype not in self . _bin_sizes : raise ValueError ( "Bin size for type %s need to be provided." % ltype ) if self . _bin_sizes [ ltype ] <= 0 : raise ValueError ( "Bin size %d need to be positive." % self . _bin_sizes [ ltype ] ) if "relative" not in self . _bin_sizes : self . _bin_sizes [ "relative" ] = 0.1