<commit_before><?php

require('./vendor/Slim/Slim/Slim.php');

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

$app->get('/list-files', function () {
        
    $it = new RecursiveDirectoryIterator("Knowledge");
    
    $display = array ( 'md' );

    $result = array ();
    $result['files'] = array ();

    foreach(new RecursiveIteratorIterator($it) as $file)
    {
        //filter files
        if (in_array(strtolower(array_pop(explode('.', $file))), $display)) {
            $dir = explode ('/', $file);
            $filename = array_pop($dir);
            $dirname = implode($dir, '/');
            $result['files'][$dirname][] = ''.$filename;
        }
    }

    echo json_encode($result);
});

$app->post('/show-file-contents', function () use ($app) {
        
    $body = $app->request->getBody();
    $body = json_decode($body);

    $filename = $body->file;
   
    $result = array ();
    $result['file']['contents']         = file_get_contents(__DIR__ . '/' . $filename);
    $result['file']['lastModifiedDate'] = date("Y-m-d H:i:s",filemtime($filename));

    echo json_encode($result);
});

$app->run();

?><commit_msg>Add: Select separator by SO (backend)<commit_after><?php

require(__DIR__ . '/vendor/Slim/Slim/Slim.php');

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();

$app->get('/list-files', function () use ($app) {
        
    $it = new RecursiveDirectoryIterator("Knowledge");
    
    $display = array ( 'md' );

    $result = array ();
    $result['files'] = array ();
    $slash = DIRECTORY_SEPARATOR;

    foreach(new RecursiveIteratorIterator($it) as $file)
    {
        //filter files
        if (in_array(strtolower(array_pop(explode('.', $file))), $display)) {
            $dir = explode ($slash, $file);
            $filename = array_pop($dir);
            $dirname = implode($dir, $slash);
            $result['files'][$dirname][] = ''.$filename;
        }
    }

    echo json_encode($result);
});

$app->post('/show-file-contents', function () use ($app) {
        
    $body = $app->request->getBody();
    $body = json_decode($body);

    $filename = $body->file;
    $slash = DIRECTORY_SEPARATOR;
   
    $result = array ();
    $result['file']['contents']         = file_get_contents(__DIR__ . $slash . $filename);
    $result['file']['lastModifiedDate'] = date("Y-m-d H:i:s",filemtime($filename));

    echo json_encode($result);
});

$app->run();

?>
{'fraction_non_alphanumeric': 0.2066694112803623, 'fraction_numerical': 0.0, 'mean_word_length': 2.838862559241706, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '1611596', 'n_tokens_mistral': 815, 'n_tokens_neox': 802, 'n_words': 135}