import re


def preprocess(text: str) -> str:
    """
    Pre-process a document for later ngramming.

    Parameters
    ----------
    text : str
        The string to pre-process

    Returns
    -------
    str
        The pre-processed string.
    """
    re_wordbeg = re.compile(r"(?<=\s)[-']")
    re_wordbeg2 = re.compile(r"(?<=\s\")[-']")
    re_wordend = re.compile(r"[-'](?=\s)")
    re_wordend2 = re.compile(r"[-'](?=\"\s)")
    text = re_wordbeg.sub("", text)
    text = re_wordbeg2.sub("", text)
    text = re_wordend.sub("", text)
    text = re_wordend2.sub("", text)
    return text