<commit_before>from django.db import models
from django.conf import settings
from model_utils import Choices
from model_utils.models import TimeStampedModel


class GeneralArtist(TimeStampedModel):

    """Any artist that might be searched for."""

    name = models.CharField(max_length=100, unique=True)
    normalized_name = models.CharField(max_length=100, editable=False,
                                       unique=True)
    similar_artists = models.ManyToManyField(to='artists.Artist',
                                             through='Similarity')

    def save(self, **kwargs):
        self.normalized_name = self.name.upper()
        return super().save(**kwargs)


class BaseSimilarity(TimeStampedModel):

    class Meta:
        abstract = True<commit_msg>Hard-code identity similarity for Artist on save<commit_after>from django.db import models
from django.db.models.signals import post_save
from django.conf import settings
from model_utils import Choices
from model_utils.models import TimeStampedModel


class GeneralArtist(TimeStampedModel):

    """Any artist that might be searched for."""

    name = models.CharField(max_length=100, unique=True)
    normalized_name = models.CharField(max_length=100, editable=False,
                                       unique=True)
    similar_artists = models.ManyToManyField(to='artists.Artist',
                                             through='Similarity')

    def save(self, **kwargs):
        self.normalized_name = self.name.upper()
        return super().save(**kwargs)


def create_general_artist(instance, created, **kwargs):
    if created:
        artist, _ = GeneralArtist.objects.get_or_create(
            normalized_name=instance.name.upper(),
            defaults={'name': instance.name},
        )
        Similarity.objects.get_or_create(cc_artist=instance,
                                         other_artist=artist, weight=5)


post_save.connect(create_general_artist, 'artists.Artist')


class BaseSimilarity(TimeStampedModel):

    class Meta:
        abstract = True
{'fraction_non_alphanumeric': 0.0892337536372454, 'fraction_numerical': 0.006304558680892337, 'mean_word_length': 2.7645985401459856, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3705847', 'n_tokens_mistral': 566, 'n_tokens_neox': 539, 'n_words': 121}