def re_configured_rating(
    s: str,
    min_score_val: int = 0,
    max_score_val: int = 3,
    allow_decimal: bool = False,
) -> int:
    """Extract a {min_score_val}-{max_score_val} rating from a string. Configurable
    to the ranges like 4-point Likert scale or binary (0 or 1).

    If the string does not match an integer/a float or matches an integer/a
    float outside the {min_score_val} - {max_score_val} range, raises an error
    instead. If multiple numbers are found within the expected 0-10 range, the
    smallest is returned.

    Args:
        s: String to extract rating from.

        min_score_val: Minimum value of the rating scale.

        max_score_val: Maximum value of the rating scale.

        allow_decimal: Whether to allow and capture decimal numbers (floats).

    Returns:
        int: Extracted rating.

    Raises:
        ParseError: If no integers/floats between 0 and 10 are found in the string.
    """
    matches = PATTERN_NUMBER.findall(s)
    if not matches:
        raise ParseError("int or float number", s, pattern=PATTERN_NUMBER)

    vals = set()
    for match in matches:
        rating = float(match) if allow_decimal else int(float(match))
        if min_score_val <= rating <= max_score_val:
            vals.add(rating)
        else:
            logger.warning(
                "Rating must be in [%s, %s].", min_score_val, max_score_val
            )

    if not vals:
        raise ParseError(f"{min_score_val}-{max_score_val} rating", s)

    if len(vals) > 1:
        logger.warning(
            "Multiple valid rating values found in the string: %s", s
        )

    # Min to handle cases like "The rating is 1 out of 3."
    return min(vals)
Extract a {min_score_val}-{max_score_val} rating from a string. Configurable
    to the ranges like 4-point Likert scale or binary (0 or 1).

    If the string does not match an integer/a float or matches an integer/a
    float outside the {min_score_val} - {max_score_val} range, raises an error
    instead. If multiple numbers are found within the expected 0-10 range, the
    smallest is returned.

    Args:
        s: String to extract rating from.

        min_score_val: Minimum value of the rating scale.

        max_score_val: Maximum value of the rating scale.

        allow_decimal: Whether to allow and capture decimal numbers (floats).

    Returns:
        int: Extracted rating.

    Raises:
        ParseError: If no integers/floats between 0 and 10 are found in the string.
    
src/feedback/trulens/feedback/generated.py