Return the value of the score based on its type. If the score type is "true_false", it returns True if the score value is "true" (case-insensitive), otherwise it returns False. If the score type is "float_scale", it returns the score value as a float. Retu
(self)
| 129 | # Public API |
| 130 | # ------------------------------------------------------------------ # |
| 131 | def get_value(self) -> bool | float: |
| 132 | """ |
| 133 | Return the value of the score based on its type. |
| 134 | |
| 135 | If the score type is "true_false", it returns True if the score value is "true" (case-insensitive), |
| 136 | otherwise it returns False. |
| 137 | |
| 138 | If the score type is "float_scale", it returns the score value as a float. |
| 139 | |
| 140 | Returns: |
| 141 | bool | float: Parsed score value. |
| 142 | |
| 143 | Raises: |
| 144 | ValueError: If the score type is unknown. |
| 145 | """ |
| 146 | if self.score_type == "true_false": |
| 147 | return self.score_value.lower() == "true" |
| 148 | if self.score_type == "float_scale": |
| 149 | return float(self.score_value) |
| 150 | |
| 151 | raise ValueError(f"Unknown scorer type: {self.score_type}") |
| 152 | |
| 153 | def __str__(self) -> str: |
| 154 | """ |
no outgoing calls