<commit_before>import random
import json
import string

class Cryptogram():
    def get_quote(self):
        f = open('quotes.txt', 'r')
        quotes = json.loads(f.read())
        quote = random.choice(quotes)

        answer = quote['Quote']
        author = quote['Author']
        category = quote['Category']

        return(answer, author, category)

    # Build cipher.
    def build_cipher(self, answer):
        answer = answer.upper()
        answer = list(answer)

        # Get uppercase letters into a list.
        alphabet = list(string.uppercase)

        # Get unique letters from original text and location of all occurrences.
        original = []

        for letter in answer:
            if(letter.isalpha() and letter not in [o['letter'] for o in original]):
                d = dict()
                d['letter'] = letter
                d['positions'] = [i for i, x in enumerate(answer) if x == letter]
                original.append(d)

        # Copy answer.
        cipher = list(answer)

        for o in original:
            # Pick a substitute letter.
            # The substitute can't be the same letter.
            choices = [x for x in alphabet if x != o['letter']]
            sub = random.choice(choices)

            # Remove chosen substitute from choices.
            alphabet.remove(sub)

            for i in o['positions']:<commit_msg>Uppercase and list() answer in get_quote().<commit_after>import random
import json
import string

class Cryptogram():
    def get_quote(self):
        # Load quotes from text file.
        f = open('quotes.txt', 'r')
        quotes = json.loads(f.read())

        # Get random quote.
        quote = random.choice(quotes)

        # Extract out the quote, author, and category.
        answer = quote['Quote']
        author = quote['Author']
        category = quote['Category']

        # Uppercase the answer and convert to list.
        answer = answer.upper()
        answer = list(answer)

        return(answer, author, category)

    # Build cipher.
    def build_cipher(self, answer):
        # Get uppercase letters into a list.
        alphabet = list(string.uppercase)

        # Get unique letters from original text and location of all occurrences.
        original = []

        for letter in answer:
            if(letter.isalpha() and letter not in [o['letter'] for o in original]):
                d = dict()
                d['letter'] = letter
                d['positions'] = [i for i, x in enumerate(answer) if x == letter]
                original.append(d)

        # Copy answer.
        cipher = list(answer)

        for o in original:
            # Pick a substitute letter.
            # The substitute can't be the same letter.
            choices = [x for x in alphabet if x != o['letter']]
            sub = random.choice(choices)

            # Remove chosen substitute from choices.
            alphabet.remove(sub)

            for i in o['positions']:
{'fraction_non_alphanumeric': 0.10067340067340068, 'fraction_numerical': 0.0, 'mean_word_length': 1.8567307692307693, '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': '7005610', 'n_tokens_mistral': 810, 'n_tokens_neox': 761, 'n_words': 274}