<commit_before>from flask import Blueprint, abort, jsonify, Response

from domain.models import Alphabet
from domain.repository import Repository

import random
import json

blueprint = Blueprint('alphabet', __name__)


@blueprint.route('/alphabet/today', methods=['GET'])
def get_today_useful_message():
    allAlphabets = Repository.db.session.query(Alphabet).all()
    return u"<br>".join([u"{0}: {1}	{2}	{3}	{4}".
                        format(item.alphabet, item.lat, item.long, item.zoom, item.image_path)
                         for item in allAlphabets])


@blueprint.route('/alphabet/text=<string:input>', methods=['GET'])
def generate_image_list(input):
    # 1. Convert unicodes or whatever!!! to string
    input = str(input)

    # 2. Check input, a word or sentence.
    if isinstance(input, str) == False:
        abort(400)
    # return 'Input is not string type. Please input as a word or a sentence.'

    # 3. Generate words list.
    words = list(input)
    if isinstance(words, list) == False:
        return "Splitting a sentence to characters was failed. Sorry."

    # 4. Generate image list which are matched to words.
    images = list()
    for item in words:
        found = search_alphabet_image(item)
        images.append(found)

    data = {
        "text": input,
        "cali": images<commit_msg>Function to retrieve a word of the day is serviced from now.<commit_after>from flask import Blueprint, abort, jsonify, Response

from domain.models import Alphabet
from domain.repository import Repository

import random
import json
import lxml.html
import re

blueprint = Blueprint('alphabet', __name__)


@blueprint.route('/alphabet/today', methods=['GET'])
def get_today_useful_message():
    title_of_the_page = lxml.html.parse('http://www.dictionary.com/wordoftheday/')
    word_of_the_day = title_of_the_page.find(".//title").text
    word_of_the_day = re.split("- |\|", word_of_the_day)
    return generate_image_list(word_of_the_day[1].strip())


@blueprint.route('/alphabet/text=<string:input>', methods=['GET'])
def generate_image_list(input):
    # 1. Convert unicodes or whatever!!! to string
    input = str(input)

    # 2. Check input, a word or sentence.
    if isinstance(input, str) == False:
        abort(400)
    # return 'Input is not string type. Please input as a word or a sentence.'

    # 3. Generate words list.
    words = list(input)
    if isinstance(words, list) == False:
        return "Splitting a sentence to characters was failed. Sorry."

    # 4. Generate image list which are matched to words.
    images = list()
    for item in words:
        found = search_alphabet_image(item)
        images.append(found)

    data = {
        "text": input,
        "cali": images
{'fraction_non_alphanumeric': 0.11565122218168551, 'fraction_numerical': 0.0072966070777088655, 'mean_word_length': 3.2577639751552794, 'pattern_counts': {'":': 4, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 2}, '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': '2961892', 'n_tokens_mistral': 857, 'n_tokens_neox': 825, 'n_words': 254}