<commit_before># THIRD PARTY
from djangae.db import transaction
from djangae.fields import CharField, SetField, RelatedSetField
from django.db import models

# PARLIAMENT TREE
from pt.core.constants import CONSTITUENCIES, PARTIES


class BaseModel(models.Model):
    """ Base model for all other models. """

    class Meta(object):
        abstract = True

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)


class MP(BaseModel):
    """ A member of parliament. """

    name = CharField()
    constituency = CharField(
        # Note that this field is unique, but is nullable so that when the MP of a constituency
        # changes we don't have to delete the old one (or their speeches), we just wipe this field
        choices=CONSTITUENCIES.choices,
        unique=True,
        null=True,
    )
    party = CharField(choices=PARTIES.choices)


class Speech(BaseModel):
    """ The words spoken by an MP in a single "speech".
        A "speech" will probably be the words spoken in a single instance of an MP standing up, but
        it might depend on how Hansard publishes the data.
    """

    mp = models.ForeignKey(MP)
    timestamp = models.DateTimeField(
        help_text="The time when the MP spoke these words (not when this was saved to the DB)"
    )
    text = models.TextField()
    keywords = SetField(
        CharField(),
        # Not sure if this should be the non-filler words, or the words which users are actually
        # following at the time when it's saved.  TBD.
        help_text="Words from the speech which are relevant for querying by"
    )
    # These fields store the number of users that have like/disliked/flagged this speech.
    # For each of these counts there is a separate "through" table between the users and the
    # speeches, but because we're on a non-relational DB and can't actually JOIN those tables, we<commit_msg>Adding a `hansard_url` to the `Speech` model.<commit_after># THIRD PARTY
from djangae.db import transaction
from djangae.fields import CharField, SetField, RelatedSetField
from django.db import models

# PARLIAMENT TREE
from pt.core.constants import CONSTITUENCIES, PARTIES


class BaseModel(models.Model):
    """ Base model for all other models. """

    class Meta(object):
        abstract = True

    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)


class MP(BaseModel):
    """ A member of parliament. """

    name = CharField()
    constituency = CharField(
        # Note that this field is unique, but is nullable so that when the MP of a constituency
        # changes we don't have to delete the old one (or their speeches), we just wipe this field
        choices=CONSTITUENCIES.choices,
        unique=True,
        null=True,
    )
    party = CharField(choices=PARTIES.choices)


class Speech(BaseModel):
    """ The words spoken by an MP in a single "speech".
        A "speech" will probably be the words spoken in a single instance of an MP standing up, but
        it might depend on how Hansard publishes the data.
    """

    mp = models.ForeignKey(MP)
    timestamp = models.DateTimeField(
        help_text="The time when the MP spoke these words (not when this was saved to the DB)"
    )
    hansard_url = models.URLField(
        help_text="The URL of where this speech is located on the Hansard website"
    )
    text = models.TextField()
    keywords = SetField(
        CharField(),
        # Not sure if this should be the non-filler words, or the words which users are actually
        # following at the time when it's saved.  TBD.
        help_text="Words from the speech which are relevant for querying by"
    )
    # These fields store the number of users that have like/disliked/flagged this speech.
    # For each of these counts there is a separate "through" table between the users and the
    # speeches, but because we're on a non-relational DB and can't actually JOIN those tables, we
{'fraction_non_alphanumeric': 0.07028913260219342, 'fraction_numerical': 0.0, 'mean_word_length': 3.041289023162135, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4005655', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1097, 'n_words': 479}