<commit_before>import requests
from django import forms

from grandchallenge.publications.models import Publication, doi_validator


class PublicationForm(forms.ModelForm):
    def clean_doi(self):
        doi = self.cleaned_data["doi"]
        doi_validator(doi)
        return doi

    def clean(self):
        self.cleaned_data = super().clean()

        if self.errors:
            return self.cleaned_data

        doi = self.cleaned_data.get("doi", self.instance.doi)

        response = requests.get(
            f"https://doi.org/{doi}",
            headers={"Accept": "application/vnd.citationstyles.csl+json"},
        )

        if response.status_code != 200:
            self.add_error("doi", "This DOI could not be found.")
        else:<commit_msg>Lower case the doi<commit_after>import requests
from django import forms

from grandchallenge.publications.models import Publication, doi_validator


class PublicationForm(forms.ModelForm):
    def clean_doi(self):
        doi = self.cleaned_data["doi"]
        doi = doi.lower()
        doi_validator(doi)
        return doi

    def clean(self):
        self.cleaned_data = super().clean()

        if self.errors:
            return self.cleaned_data

        doi = self.cleaned_data.get("doi", self.instance.doi)

        response = requests.get(
            f"https://doi.org/{doi}",
            headers={"Accept": "application/vnd.citationstyles.csl+json"},
        )

        if response.status_code != 200:
            self.add_error("doi", "This DOI could not be found.")
        else:
{'fraction_non_alphanumeric': 0.11175337186897881, 'fraction_numerical': 0.0038535645472061657, 'mean_word_length': 2.4317180616740086, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2752246', 'n_tokens_mistral': 491, 'n_tokens_neox': 433, 'n_words': 98}