def get_tags(tweet, lower=False):
    """Extract tags from a tweet"""
    try:
        ent = tweet.get('entities', [])
        if not ent:
            return []
        if lower:
            return (tag['text'].lower() for tag in ent.get('hashtags', []))
        return set(tag['text'] for tag in ent.get('hashtags', []))
    except KeyError as e:
        print("get_tags got KeyError")