<commit_before># -*- coding: utf-8 -*-
from flask import *
import random
from random import randint
import os

app = Blueprint('alphabet', __name__)

abc = u"abcdefghijklmnopqrstuvwxyz"

#words = ["ananas", "banana", "cesta", "dom", "eskim", "figa"]

# get words from file static/words.txt
file = open("static/words.txt","r") 
words = file.read().splitlines()
file.close()


def select_word(list_words):
    return list_words[randint(0, len(list_words)-1)]

def select_letter(letters):
    return abc[randint(0, len(abc) - 1)]
    
def return_choices(letter):
    numChoices = 4
    choices = random.sample(range(0, len(abc)), numChoices)
    for i in range(0, numChoices):
        choices[i] = abc[choices[i]]
    if letter not in choices:
        choices[0] = letter
        random.shuffle(choices)
    return choices

def alphabet_exists(alphabet):
    return os.path.isdir("static/images/" + alphabet)

@app.route("/")
@app.route("/<selected_alphabet>/")<commit_msg>Words in database instead of text file<commit_after># -*- coding: utf-8 -*-
from flask import *
import random
from random import randint
import os
from database import database

app = Blueprint('alphabet', __name__)

abc = u"abcdefghijklmnopqrstuvwxyz"

# get words from database
def get_all_words():
    db = database.dbcon()
    cur = db.cursor()
    cur.execute("SELECT Word FROM Words")
    return [row[0] for row in cur]
words = get_all_words()

def select_word(list_words):
    return list_words[randint(0, len(list_words)-1)]

def select_letter(letters):
    return abc[randint(0, len(abc) - 1)]
    
def return_choices(letter):
    numChoices = 4
    choices = random.sample(range(0, len(abc)), numChoices)
    for i in range(0, numChoices):
        choices[i] = abc[choices[i]]
    if letter not in choices:
        choices[0] = letter
        random.shuffle(choices)
    return choices

def alphabet_exists(alphabet):
    return os.path.isdir("static/images/" + alphabet)

@app.route("/")
@app.route("/<selected_alphabet>/")
{'fraction_non_alphanumeric': 0.13872255489021956, 'fraction_numerical': 0.009481037924151697, 'mean_word_length': 3.9751861042183623, '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': '166198', 'n_tokens_mistral': 701, 'n_tokens_neox': 685, 'n_words': 172}