<commit_before>#include <common.h>
#include <Parser.h>
#include <Tokenizer.h>
#include <Configuration.h>
#include <ErrorProcessor.h>
#include <PatternsFileProcessor.h>

using namespace Lspl::Parser;
using namespace Lspl::Pattern;
using namespace Lspl::Configuration;

int main( int argc, const char* argv[] )
{
	try {
		if( argc != 4 ) {
			cerr << "Usage: lspl2 CONFIGURATION PATTERNS TEXT" << endl;
			return 1;
		}

		CConfigurationPtr conf = LoadConfigurationFromFile( argv[1], cerr, cout );

		if( !static_cast<bool>( conf ) ) {
			return 1;
		}

		CErrorProcessor errorProcessor;
		CPatternsBuilder patternsBuilder( conf, errorProcessor );
		patternsBuilder.Read( argv[2] );
		patternsBuilder.Check();

		if( errorProcessor.HasAnyErrors() ) {
			errorProcessor.PrintErrors( cerr, argv[2] );
			return 1;
		}

		const CPatterns patterns = patternsBuilder.Save();
		patterns.Print( cout );<commit_msg>test main version<commit_after>#include <common.h>
#include <Parser.h>
#include <Tokenizer.h>
#include <TextLoader.h>
#include <PatternMatch.h>
#include <Configuration.h>
#include <ErrorProcessor.h>
#include <PatternsFileProcessor.h>

using namespace Lspl;
using namespace Lspl::Text;
using namespace Lspl::Parser;
using namespace Lspl::Pattern;
using namespace Lspl::Configuration;

int main( int argc, const char* argv[] )
{
	try {
		if( argc != 4 ) {
			cerr << "Usage: lspl2 CONFIGURATION PATTERNS TEXT" << endl;
			return 1;
		}

		CConfigurationPtr conf = LoadConfigurationFromFile( argv[1], cerr, cout );

		if( !static_cast<bool>( conf ) ) {
			return 1;
		}

		CErrorProcessor errorProcessor;
		CPatternsBuilder patternsBuilder( conf, errorProcessor );
		patternsBuilder.Read( argv[2] );
		patternsBuilder.Check();

		if( errorProcessor.HasAnyErrors() ) {
			errorProcessor.PrintErrors( cerr, argv[2] );
			return 1;
		}

		const CPatterns patterns = patternsBuilder.Save();
		patterns.Print( cout );

		CWords words;
		LoadText( patterns, argv[3], words );
		CText text( move( words ) );

		for( TReference ref = 0; ref < patterns.Size(); ref++ ) {
			const CPattern& pattern = patterns.Pattern( ref );
			cout << pattern.Name() << endl;
			CStates states;
			{
				CPatternBuildContext buildContext( patterns );
				CPatternVariants variants;
				pattern.Build( buildContext, variants, 12 );
				states = move( variants.Build( patterns ) );
			}
			{
				CMatchContext matchContext( text, states );
				for( TWordIndex wi = 0; wi < text.Length(); wi++ ) {
					matchContext.Match( wi );
				}
			}
			cout << endl;
		}
{'fraction_non_alphanumeric': 0.13022888713496447, 'fraction_numerical': 0.008287292817679558, 'mean_word_length': 4.184049079754601, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 19, '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': '7167695', 'n_tokens_mistral': 937, 'n_tokens_neox': 810, 'n_words': 215}