class_docstr: Computes the entity consistency distribution
docstr: Simplifies the aggregation result sorting by worst mention consistency
docstr_tok: ["Simplifies","the","aggregation","result","sorting","by","worst","mention","consistency"]
code: def aggregation_result(
      self, aggregation_result: Dict[str, Any]
  ) -> Dict[str, Any]:
      """Simplifies the aggregation result sorting by worst mention consistency"""
      result = [
          {
              "mention": mention,
              "entities": [
                  {"label": entity, "count": count}
                  for entity, count in mention_aggs["entities"].items()
              ],
          }
          for mention, mention_aggs in aggregation_result.items()
      ]
      # TODO: filter by entities threshold
      result.sort(key=lambda m: len(m["entities"]), reverse=True)
      return {"mentions": result}
  
file_path: argilla/src/argilla/server/daos/backend/metrics/token_classification.py
imports: import dataclasses
  from typing import Any, Dict
  from argilla.server.daos.backend.metrics.base import BidimensionalTermsAggregation, HistogramAggregation, NestedBidimensionalTermsAggregation, NestedHistogramAggregation, NestedPathElasticsearchMetric, NestedTermsAggregation, TermsAggregation
  from argilla.server.daos.backend.query_helpers import aggregations
label_desc: Use image node_id 2 for calling the TopKMentionsConsistency obj's underlying member method code with example usage: obj.aggregation_result(aggregation_result) and returns: dict