<commit_before># Django
from django.contrib.auth.models import User

try:
    # Django < 1.10
    from django.contrib.contenttypes.generic import GenericForeignKey
except ImportError:
    # Django >= 1.10
    from django.contrib.contenttypes.fields import GenericForeignKey

from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models


def get_sentinel_user():
    return User.objects.get_or_create(username='deleted')[0]


class NestedComment(models.Model):
    content_type = models.ForeignKey(
        ContentType,
    )

    object_id = models.PositiveIntegerField()

    content_object = GenericForeignKey(
        'content_type',
        'object_id',
    )

    author = models.ForeignKey(
        User,
        on_delete = models.SET(get_sentinel_user),
        editable = False,
    )

    text = models.TextField()

    created = models.DateTimeField(
        auto_now_add = True,
        editable = False,
    )

    updated = models.DateTimeField(
        auto_now = True,
        editable = False,
    )

    parent = models.ForeignKey(
        'self',
        null = True,
        blank = True,
        related_name = 'children',
        on_delete = models.SET_NULL,
    )

    deleted = models.BooleanField(
        default = False,
    )

    def __unicode__(self):
        return "%s: \"%s\"" % (self.author, self.text)

    def get_absolute_url(self):
        object_url = self.content_type.get_object_for_this_type(id = self.object_id).get_absolute_url()
        return '%s#c%d' % (object_url, self.id)

    def delete(self):
        if self.deleted == False:
            self.deleted = True;<commit_msg>(comments) Simply use the pk as __unicode__<commit_after># Django
from django.contrib.auth.models import User

try:
    # Django < 1.10
    from django.contrib.contenttypes.generic import GenericForeignKey
except ImportError:
    # Django >= 1.10
    from django.contrib.contenttypes.fields import GenericForeignKey

from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.db import models


def get_sentinel_user():
    return User.objects.get_or_create(username='deleted')[0]


class NestedComment(models.Model):
    content_type = models.ForeignKey(
        ContentType,
    )

    object_id = models.PositiveIntegerField()

    content_object = GenericForeignKey(
        'content_type',
        'object_id',
    )

    author = models.ForeignKey(
        User,
        on_delete = models.SET(get_sentinel_user),
        editable = False,
    )

    text = models.TextField()

    created = models.DateTimeField(
        auto_now_add = True,
        editable = False,
    )

    updated = models.DateTimeField(
        auto_now = True,
        editable = False,
    )

    parent = models.ForeignKey(
        'self',
        null = True,
        blank = True,
        related_name = 'children',
        on_delete = models.SET_NULL,
    )

    deleted = models.BooleanField(
        default = False,
    )

    def __unicode__(self):
        return "Comment %d" % self.pk

    def get_absolute_url(self):
        object_url = self.content_type.get_object_for_this_type(id = self.object_id).get_absolute_url()
        return '%s#c%d' % (object_url, self.id)

    def delete(self):
        if self.deleted == False:
            self.deleted = True;
{'fraction_non_alphanumeric': 0.09657594381035997, 'fraction_numerical': 0.004097161252560726, 'mean_word_length': 2.63230605738576, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2941354', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1006, 'n_words': 218}