improve result cutting when a POI comes out with top importance

This commit is contained in:
Sarah Hoffmann
2025-06-01 12:00:36 +02:00
parent 90050de717
commit 87a8c246a0

View File

@@ -118,17 +118,20 @@ class ForwardGeocoder:
""" Remove badly matching results, sort by ranking and """ Remove badly matching results, sort by ranking and
limit to the configured number of results. limit to the configured number of results.
""" """
if results: results.sort(key=lambda r: (r.ranking, 0 if r.bbox is None else -r.bbox.area))
results.sort(key=lambda r: (r.ranking, 0 if r.bbox is None else -r.bbox.area))
min_rank = results[0].rank_search
min_ranking = results[0].ranking
results = SearchResults(r for r in results
if (r.ranking + 0.03 * (r.rank_search - min_rank)
< min_ranking + 0.5))
results = SearchResults(results[:self.limit]) final = SearchResults()
min_rank = results[0].rank_search
min_ranking = results[0].ranking
return results for r in results:
if r.ranking + 0.03 * (r.rank_search - min_rank) < min_ranking + 0.5:
final.append(r)
min_rank = min(r.rank_search, min_rank)
if len(final) == self.limit:
break
return final
def rerank_by_query(self, query: QueryStruct, results: SearchResults) -> None: def rerank_by_query(self, query: QueryStruct, results: SearchResults) -> None:
""" Adjust the accuracy of the localized result according to how well """ Adjust the accuracy of the localized result according to how well