<commit_before>import re

from flask import Flask, Response
from molt_core import molt

app = Flask(__name__)


@app.route('/<virtual_host>', methods=['POST'])
def index(virtual_host):
    rev, repo, user = virtual_host_parse(virtual_host)

    def generate():     # For streaming
        for row in molt(rev, repo, user):
            yield row
    return Response(generate(), mimetype='text/text')


def virtual_host_parse(virtual_host):
    """ virtual_hostの文字列を 'rev', 'repo', 'user' に分割する
    e.g.(1) "host.repo.sitory.user" => "host", "repo.sitory", "user"
    e.g.(2) "host.repository.user" => "host", "repository", "user"
    """
    p = re.compile(r'(?P<rev>^.+?)\.(?P<repo>.+)\.(?P<user>.+)$')
    m = p.search(virtual_host)
    return m.group('rev'), m.group('repo'), m.group('user')
<commit_msg>:art: molt_coreのクラス化に伴い関数呼び出しの修正<commit_after>import re

from flask import Flask, Response
from molt_core import Molt

app = Flask(__name__)


@app.route('/<virtual_host>', methods=['POST'])
def index(virtual_host):
    rev, repo, user = virtual_host_parse(virtual_host)
    m = Molt(rev, repo, user)

    def generate(m):     # For streaming
        for row in m.molt():
            yield row
    return Response(generate(m), mimetype='text/text')


def virtual_host_parse(virtual_host):
    """ virtual_hostの文字列を 'rev', 'repo', 'user' に分割する
    e.g.(1) "host.repo.sitory.user" => "host", "repo.sitory", "user"
    e.g.(2) "host.repository.user" => "host", "repository", "user"
    """
    p = re.compile(r'(?P<rev>^.+?)\.(?P<repo>.+)\.(?P<user>.+)$')
    m = p.search(virtual_host)
    return m.group('rev'), m.group('repo'), m.group('user')

{'fraction_non_alphanumeric': 0.19515151515151516, 'fraction_numerical': 0.0024242424242424242, 'mean_word_length': 3.827485380116959, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5576911', 'n_tokens_mistral': 628, 'n_tokens_neox': 618, 'n_words': 125}