from abc import ABC, abstractmethod
from typing import Any, Optional


class Metric(ABC):
    """
    Abstract class for evaluation metrics in text generation tasks.
    This class provides a template for implementing various evaluation metrics.
    """

    _name = "Metric"

    @staticmethod
    @abstractmethod
    def evaluate(generated_text: str, reference_texts: list[str], dataset_id: Optional[str]) -> dict[str, Any]:
        """
        Evaluate the generated text against a reference text.

        Args:
        generated_text (str): The text generated by the model.
        reference_text (list[str]): The reference text to compare against.

        Returns:
        dict[str, Any]: The evaluation results.
        """

    @property
    def name(self) -> str:
        """
        Return the name of the evaluation metric.

        Returns:
        str: The name of the metric.
        """
        return self._name
