def replace_macrons_with_latex_overline(text: str) -> str:
    """Replace letters with macrons with the LaTeX bar."""
    result = []
    for char in text:
        if char.isalpha():
            decomposed = unicodedata.normalize("NFD", char)
            if len(decomposed) > 1 and decomposed[1] == "\u0304":  # Macron accent
                result.append(f"\\overline{{{decomposed[0]}}}")
            else:
                result.append(char)
        elif char != "\u0304":
            result.append(char)
        else:
            result[-1] = f"\\overline{{{result[-1]}}}"

    return "".join(result)
Replace letters with macrons with the LaTeX bar.
vlmeval/dataset/utils/megabench/scoring/common/transformations.py