<commit_before><?php

/*
 * This file is part of the KnowledgePlan website.
 *
 * (c) 2012 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once 'bootstrap.php';

use Symfony\Component\HttpFoundation\Response;

$app->get('/', function() use ($app) {

    return $app['twig']->render('homepage.html.twig');
})->bind('homepage');

$app->match('/change', function() use ($app) {
    $form = $app['form.factory']->createBuilder('form')
                                ->add('file', 'file', array('label' => 'Simulation file'))
                                ->getForm();

    if ('POST' === $app['request']->getMethod()) {
        $form->bindRequest($app['request']);

        if ($form->isValid()) {
            $oldSimulationName = $app['kp.output_file'];
            $newSimulationName = $oldSimulationName.'_new';

            $data = $form->getData();
            $newSimulationFile = $data['file'];

            // Move the file to the correct folder
            $newSimulationFile->move(dirname($newSimulationName), basename($newSimulationName));

            // Is it a correct simulation output file?
            try {
                $app['kp.simulation_manager']->get($newSimulationName, true, false);
                $isCorrect = true;
            } catch (\Exception $e) {
                $isCorrect = false;
            }

            if (false === $isCorrect) {
                // Remove the uncorrect file<commit_msg>tweaks<commit_after><?php

/*
 * This file is part of the KnowledgePlan website.
 *
 * (c) 2012 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once 'bootstrap.php';

use Symfony\Component\HttpFoundation\Response;

$app->get('/', function() use ($app) {

    return $app['twig']->render('homepage.html.twig');
})->bind('homepage');

$app->match('/change', function() use ($app) {
    $form = $app['form.factory']->createBuilder('form')
                                ->add('file', 'file', array('label' => 'Simulation file'))
                                ->getForm();

    if ('POST' === $app['request']->getMethod()) {
        $form->bindRequest($app['request']);

        if ($form->isValid()) {
            $oldSimulationName = $app['kp.output_file'];
            $newSimulationName = $oldSimulationName.'_new';

            $data = $form->getData();
            $newSimulationFile = $data['file'];

            // Move the file to the correct folder
            $newSimulationFile->move(dirname($newSimulationName), basename($newSimulationName));

            // Is it a correct simulation output file?
            try {
                $app['kp.simulation_manager']->get($newSimulationName, true, false);
                $correct = true;
            } catch (\Exception $e) {
                $correct = false;
            }

            if (false === $correct) {
                // Remove the uncorrect file
{'fraction_non_alphanumeric': 0.15966112740306287, 'fraction_numerical': 0.002606712284131639, 'mean_word_length': 2.228180862250263, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 37, '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': '5663118', 'n_tokens_mistral': 869, 'n_tokens_neox': 831, 'n_words': 205}