def remove_non_seriasable(d):
    """ Converts AnnotationType and EntityType classes to strings. This is
    needed when saving to a file.
    """
    return {
        k: str(val.name).lower() if k in ('annotation_type',
                                          'entity_type') else val
        for k, val in d.items()
    }