import re


def build_event_set(event):
    """
    Turn an EventStream event into a set of event types that ORES
    uses internally.
    """
    event_set = set()
    if re.match(r"([^\.]+.)?mediawiki\.revision-create$",
                event['meta']['topic']):
        event_set.add('edit')

        user_groups = event.get('performer', {}).get('user_groups', [])
        if 'bot' in user_groups:
            event_set.add('bot_edit')
        else:
            event_set.add('nonbot_edit')

        if event['rev_parent_id'] == 0:
            event_set.add('page_creation')
            if 'bot' in user_groups:
                event_set.add('bot_page_creation')
            else:
                event_set.add('nonbot_page_creation')

    return event_set