<commit_before>"""
    Schema for bill objects.
"""

from .common import sources, extras, fuzzy_date_blank, fuzzy_date
from opencivicdata import common

versions_or_documents = {
    "items": {
        "properties": {
            "note": {"type": "string"},
            "date": fuzzy_date_blank,
            "links": {
                "items": {
                    "properties": {
                        "media_type": {"type": "string", "blank": True },
                        "url": {"type": "string", "format": "uri"}
                    },
                    "type": "object"
                },
                "type": "array",
            },
        },
        "type": "object"
    },
    "type": "array",
}

schema = {
    "type": "object",
    "properties": {
        "legislative_session": {"type": "string"},
        "identifier": {"type": "string"},
        "title": {"type": "string"},
        "from_organization": { "type": ["string", "null"] },
        "classification": {"items": {"type": "string", "enum": common.BILL_CLASSIFICATIONS},
                           "type": "array"},
        "subject": { "items": {"type": "string"}, "type": "array"},
        "abstracts": {
            "items": {
                "properties": {
                    "abstract": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                },
                "type": "object"},
            "type": "array",
        },
        "other_titles": {
            "items": {
                "properties": {
                    "title": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                },
                "type": "object"
            },
            "type": "array",
        },
        "other_identifiers": {
            "items": {
                "properties": {
                    "identifier": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                    "scheme": {"type": "string", "blank": True},
                },
                "type": "object"
            },
            "type": "array",
        },
        "actions": {
            "items": {
                "properties": {
                    "organization": { "type": ["string", "null"] },
                    "date": fuzzy_date,
                    "description": { "type": "string" },
                    "classification": {"items": {"type": "string",
                                                  "enum": common.BILL_ACTION_CLASSIFICATIONS },
                                       "type": "array",
                                      },
                    "related_entities": {
                        "items": {
                            "properties": {
                                "name": {"type": "string"},
                                "entity_type": {
                                    "enum": ["organization", "person", ""],
                                    "type": "string", "blank": True,
                                },
                                "id": {"type": ["string", "null"]}
                                # TODO^^should this be person_id or organization_id
                            },
                            "type": "object"
                        },
                        "type": "array",
                    },
                },
                "type": "object"
            },
            "type": "array",
        },

        "sponsorships": {
            "items": {
                "properties": {
                    "primary": { "type": "boolean" },
                    "classification": { "type": "string", },
                    "name": {"type": "string" },
                    "entity_type": {
                        "enum": ["organization", "person", ""],
                        "type": "string", "blank": True,
                    },
                    "id": {"type": ["string", "null"] },
                    # ^^^TODO: check this one too
                },
                "type": "object"
            },
            "type": "array",
        },

        "related_bills": {
            "items": {
                "properties": {
                    "identifier": {"type": "string"},
                    "legislative_session": {"type": "string"},
                    "relation_type": {"enum": common.BILL_RELATION_TYPES, "type": "string"},
                },
                "type": "object"
            },
            "type": "array",
        },

        "versions": versions_or_documents,<commit_msg>update schemas to use actual names of related ids<commit_after>"""
    Schema for bill objects.
"""

from .common import sources, extras, fuzzy_date_blank, fuzzy_date
from opencivicdata import common

versions_or_documents = {
    "items": {
        "properties": {
            "note": {"type": "string"},
            "date": fuzzy_date_blank,
            "links": {
                "items": {
                    "properties": {
                        "media_type": {"type": "string", "blank": True },
                        "url": {"type": "string", "format": "uri"}
                    },
                    "type": "object"
                },
                "type": "array",
            },
        },
        "type": "object"
    },
    "type": "array",
}

schema = {
    "type": "object",
    "properties": {
        "legislative_session": {"type": "string"},
        "identifier": {"type": "string"},
        "title": {"type": "string"},
        "from_organization": { "type": ["string", "null"] },
        "classification": {"items": {"type": "string", "enum": common.BILL_CLASSIFICATIONS},
                           "type": "array"},
        "subject": { "items": {"type": "string"}, "type": "array"},
        "abstracts": {
            "items": {
                "properties": {
                    "abstract": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                },
                "type": "object"},
            "type": "array",
        },
        "other_titles": {
            "items": {
                "properties": {
                    "title": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                },
                "type": "object"
            },
            "type": "array",
        },
        "other_identifiers": {
            "items": {
                "properties": {
                    "identifier": {"type": "string"},
                    "note": {"type": "string", "blank": True},
                    "scheme": {"type": "string", "blank": True},
                },
                "type": "object"
            },
            "type": "array",
        },
        "actions": {
            "items": {
                "properties": {
                    "organization": { "type": ["string", "null"] },
                    "date": fuzzy_date,
                    "description": { "type": "string" },
                    "classification": {"items": {"type": "string",
                                                  "enum": common.BILL_ACTION_CLASSIFICATIONS },
                                       "type": "array",
                                      },
                    "related_entities": {
                        "items": {
                            "properties": {
                                "name": {"type": "string"},
                                "entity_type": {
                                    "enum": ["organization", "person", ""],
                                    "type": "string", "blank": True,
                                },
                                "person_id": {"type": ["string", "null"]},
                                "organization_id": {"type": ["string", "null"]},
                            },
                            "type": "object"
                        },
                        "type": "array",
                    },
                },
                "type": "object"
            },
            "type": "array",
        },

        "sponsorships": {
            "items": {
                "properties": {
                    "primary": { "type": "boolean" },
                    "classification": { "type": "string", },
                    "name": {"type": "string" },
                    "entity_type": {
                        "enum": ["organization", "person", ""],
                        "type": "string", "blank": True,
                    },
                    "person_id": {"type": ["string", "null"] },
                    "organization_id": {"type": ["string", "null"] },
                },
                "type": "object"
            },
            "type": "array",
        },

        "related_bills": {
            "items": {
                "properties": {
                    "identifier": {"type": "string"},
                    "legislative_session": {"type": "string"},
                    "relation_type": {"enum": common.BILL_RELATION_TYPES, "type": "string"},
                },
                "type": "object"
            },
            "type": "array",
        },

        "versions": versions_or_documents,
{'fraction_non_alphanumeric': 0.16942328618063113, 'fraction_numerical': 0.0, 'mean_word_length': 1.0231124807395995, 'pattern_counts': {'":': 260, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 13, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5802655', 'n_tokens_mistral': 2325, 'n_tokens_neox': 2156, 'n_words': 466}