| @@ 234-244 (lines=11) @@ | ||
| 231 | words = phrase.split() |
|
| 232 | return " ".join(sorted(words)) |
|
| 233 | ||
| 234 | def _combine_suggestions( |
|
| 235 | self, suggestions: list[tuple[str, float]] |
|
| 236 | ) -> list[tuple[str, float]]: |
|
| 237 | combined_suggestions = {} |
|
| 238 | for uri, score in suggestions: |
|
| 239 | if uri not in combined_suggestions: |
|
| 240 | combined_suggestions[uri] = score |
|
| 241 | else: |
|
| 242 | old_score = combined_suggestions[uri] |
|
| 243 | combined_suggestions[uri] = self._combine_scores(score, old_score) |
|
| 244 | return list(combined_suggestions.items()) |
|
| 245 | ||
| 246 | def _combine_scores(self, score1: float, score2: float) -> float: |
|
| 247 | # The result is never smaller than the greater input |
|
| @@ 171-181 (lines=11) @@ | ||
| 168 | score = max(score, 0) |
|
| 169 | return 1.0 / (score + 1) |
|
| 170 | ||
| 171 | def _combine_suggestions( |
|
| 172 | self, suggestions: list[tuple[str, float]] |
|
| 173 | ) -> list[tuple[str, float]]: |
|
| 174 | combined_suggestions = {} |
|
| 175 | for uri, score in suggestions: |
|
| 176 | if uri not in combined_suggestions: |
|
| 177 | combined_suggestions[uri] = score |
|
| 178 | else: |
|
| 179 | old_score = combined_suggestions[uri] |
|
| 180 | combined_suggestions[uri] = self._combine_scores(score, old_score) |
|
| 181 | return list(combined_suggestions.items()) |
|
| 182 | ||
| 183 | def _combine_scores(self, score1: float, score2: float) -> float: |
|
| 184 | # The result is never smaller than the greater input |
|