from typing import Tuple
from typing import List
from typing import Optional
import re


def make_alts_from_text(text: str) -> Tuple[List[str], Optional[str]]:
    """
    Create test example from raw string.

    To test context pass the value with text like:

    ```python
    "I need fruit juice" | COF1
    ```

    Args:
        text (str): Raw string test input.

    Returns:
        Tuple[List[str], Optional[str]]
    """
    context: Optional[str]

    if "|" in text:
        text_, context = text.split("|")
        context_ = context.strip()
    else:
        text_ = text
        context_ = None

    text_ = re.sub(r"\s+", " ", re.sub(r"[^a-zA-Z0-9 ]+", " ", text_)).lower().strip()
    return [text_], context_