<commit_before># -*- coding: utf-8 -*-
from os.path import commonprefix

from django.conf import settings
from django.db import models

from grandchallenge.cases.models import (
    Image,
    RawImageUploadSession,
    RawImageFile,
)
from grandchallenge.challenges.models import Challenge
from grandchallenge.container_exec.models import ContainerExecJobModel
from grandchallenge.core.models import UUIDModel
from grandchallenge.core.urlresolvers import reverse
from grandchallenge.evaluation.models import Submission
from grandchallenge.jqfileupload.models import StagedFile


class IndexMixin:
    @property
    def index(self):
        images = self.images.all()
        common_prefix = commonprefix([i.name for i in images])
        return {i.sorter_key(start=len(common_prefix)): i for i in images}


class ImageSet(UUIDModel, IndexMixin):
    TRAINING = "TRN"
    TESTING = "TST"<commit_msg>Lowers the filename for key<commit_after># -*- coding: utf-8 -*-
from os.path import commonprefix
from typing import Union

from django.conf import settings
from django.db import models

from grandchallenge.cases.models import (
    Image,
    RawImageUploadSession,
    RawImageFile,
)
from grandchallenge.challenges.models import Challenge
from grandchallenge.container_exec.models import ContainerExecJobModel
from grandchallenge.core.models import UUIDModel
from grandchallenge.core.urlresolvers import reverse
from grandchallenge.evaluation.models import Submission
from grandchallenge.jqfileupload.models import StagedFile


class IndexMixin:
    @property
    def index(self: Union["ImageSet", "AnnotationSet"]):
        images = self.images.all()
        common_prefix = commonprefix([i.name.lower() for i in images])
        return {i.sorter_key(start=len(common_prefix)): i for i in images}


class ImageSet(UUIDModel, IndexMixin):
    TRAINING = "TRN"
    TESTING = "TST"
{'fraction_non_alphanumeric': 0.07921318447634237, 'fraction_numerical': 0.001063264221158958, 'mean_word_length': 4.568047337278107, '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': '5091771', 'n_tokens_mistral': 560, 'n_tokens_neox': 521, 'n_words': 153}