"""Utility helper functions for tmlr_reviewer package."""
import re
from typing import Dict
__all__ = [
"extract_all_tags",
"extract_output_tags",
"parse_json_from_text",
]
def extract_all_tags(text: str) -> Dict[str, str]:
"""Extracts content between any XML-style tags from a string.
Args:
text: Input string that may contain tags
Returns:
Mapping of tag name -> tag content with surrounding whitespace stripped.
"""
pattern = r"<(\w+)>(.*?)\1>"
matches = re.findall(pattern, text, re.DOTALL)
return {tag: content.strip() for tag, content in matches}
def extract_output_tags(text: str) -> str:
"""Extract content between tags from *text* if present.
Args:
text: Arbitrary string that may contain output tags.
Returns:
The content inside the first pair of