def load_fragment(soup, fragment, cache):
    """
    Load and cache a BNC fragment, given the id `fragment`.
    """
    if fragment in cache:
        return cache[fragment]
    fragment_xml = soup.find('text', {'xml:id': fragment})
    cache[fragment] = fragment_xml
    return fragment_xml