<commit_before><?php namespace Buonzz\Scalp\Commands\Metadata;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use Buonzz\Scalp\Analyzer;
use Buonzz\Scalp\MediaFilesList;

class AnalyzeCommand extends Command
{
    protected function configure()
    {
        $this
            ->setName('metadata:analyze')
            ->setDescription('Read metadata of files to a JSON format');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        

        $analyzer = new Analyzer();
        // $data = $analyzer->analyze($file, true);

        $source_folder = getenv('INPUT_FOLDER');
        $destination_folder = getenv('OUTPUT_FOLDER');

        if(!file_exists($source_folder))
        {        $output->writeln('<error>the "'. $source_folder .'" folder doesn\'t exists!</error>');
            exit;
        }

        if(!file_exists($destination_folder))
        {
            mkdir($destination_folder);
        }

        $output->writeln("reading files from " . $source_folder);

        var_dump(MediaFilesList::get($source_folder));
    }

}<commit_msg>read data and write data to json<commit_after><?php namespace Buonzz\Scalp\Commands\Metadata;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use Buonzz\Scalp\Analyzer;
use Buonzz\Scalp\MediaFilesList;

class AnalyzeCommand extends Command
{
    protected function configure()
    {
        $this
            ->setName('metadata:analyze')
            ->setDescription('Read metadata of files to a JSON format');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        
        $analyzer = new Analyzer();

        $source_folder = getenv('INPUT_FOLDER');
        $destination_folder = getenv('OUTPUT_FOLDER');

        if(!file_exists($source_folder))
        {        $output->writeln('<error>the "'. $source_folder .'" folder doesn\'t exists!</error>');
            exit;
        }

        if(!file_exists($destination_folder))
        {
            mkdir($destination_folder);
        }

        $output->writeln("reading files from " . $source_folder);

        $files = MediaFilesList::get($source_folder);
        
        foreach($files as $k=>$file)
        {
            $data = $analyzer->analyze($file->getRealPath(),true);
            $filename = $destination_folder . "/" . $file->getFilename() . ".json";
            file_put_contents($filename, $data);
        }
    }

}
{'fraction_non_alphanumeric': 0.12548330404217925, 'fraction_numerical': 0.0, 'mean_word_length': 2.8668478260869565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 20, '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': '5923943', 'n_tokens_mistral': 816, 'n_tokens_neox': 797, 'n_words': 143}