<commit_before>from oppgavegen.models import *
import json


def format_domain():
    """Formats the random_domain for templates from the old format to the new one."""
    templates = Template.objects.all()
    letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
               'v', 'w']
    hardcoded_variables = ['R0R', 'R1R', 'R2R', 'R3R', 'R4R', 'R5R', 'R6R', 'R7R', 'R8R', 'R9R', 'R10R',
                           'R11R', 'R12R', 'R13R', 'R14R', 'R15R', 'R16R', 'R17R', 'R18R', 'R19R', 'R20R', 'R21R', 'R22R']

    for t in templates:
        try:
            variables_used = (t.used_variables).split()
        except Exception:
            pass

        variable_list = []
        try:
            for x in variables_used:
                variable_list.append(hardcoded_variables[letters.index(x.split('§')[1])])
        except Exception:
            pass

        domain_list = t.random_domain.split('§')
        domain_dict = {}
        counter = 0
        for x in reversed(domain_list):
            try:
                domain_dict[variable_list[counter]] = [x, False]
            except Exception:
                domain_dict[hardcoded_variables[counter]] = [x, False]
            counter += 1

        t.random_domain = json.dumps(domain_dict)
        t.save()
    return<commit_msg>fixed url config, also fixed db_format.<commit_after>from oppgavegen.models import *
import json


def format_domain():
    """Formats the random_domain for templates from the old format to the new one."""
    templates = Template.objects.all()
    letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
               'v', 'w']
    hardcoded_variables = ['R0R', 'R1R', 'R2R', 'R3R', 'R4R', 'R5R', 'R6R', 'R7R', 'R8R', 'R9R', 'R10R',
                           'R11R', 'R12R', 'R13R', 'R14R', 'R15R', 'R16R', 'R17R', 'R18R', 'R19R', 'R20R', 'R21R', 'R22R']

    for t in templates:
        try:
            variables_used = (t.used_variables).split()
        except Exception:
            pass

        variable_list = []
        try:
            for x in variables_used:
                variable_list.append(hardcoded_variables[letters.index(x.split('§')[1])])
        except Exception:
            pass

        domain_list = t.random_domain.split('§')
        domain_dict = {}
        counter = 0
        for x in reversed(domain_list):
            try:
                domain_dict[variable_list[counter]] = [x.split(), False]
            except Exception:
                domain_dict[hardcoded_variables[counter]] = [x.split(), False]
            counter += 1

        t.random_domain = json.dumps(domain_dict)
        t.save()
    return
{'fraction_non_alphanumeric': 0.1728395061728395, 'fraction_numerical': 0.02832244008714597, 'mean_word_length': 2.1485714285714286, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6065368', 'n_tokens_mistral': 987, 'n_tokens_neox': 930, 'n_words': 230}