<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BtrieveWrapper.Orm.Models.Generator
{
    class Program
    {
        static int Main(string[] args) {
#if DEBUG
#else
            try {
#endif
                Arguments arguments;
                try {
                    arguments = Arguments.Parse(args);
                } catch {
                    throw new ArgumentException();
                }
                foreach (var assemly in arguments.Assemblies) {
                    foreach (var type in assemly.GetTypes()) {
                        if (type.GetInterfaces().Any(i => i == typeof(IModelInitializable))) {
                            var initializable = (IModelInitializable)Activator.CreateInstance(type);
                            initializable.Initialize();
                        }
                    }
                }
                switch (arguments.Mode) {
                    case OperationMode.GenerateModelFromDdf: {
                            Console.WriteLine("Mode {0}", arguments.Mode);
                            var uri = arguments.Uri;
                            if (uri == null) {
                                throw new ArgumentException();
                            }
                            var model = Model.FromDdf(uri.UriHost, uri.UriDbName, uri.UriUser, uri.UriPassword, uri.UriPrompt, null, arguments.BtrieveLibrary);
                            if (System.IO.File.Exists(arguments.Output) && !arguments.Silent) {
                                for (; ; ) {
                                    Console.WriteLine(@"""{0}"" already exists. Overwrite it? (y/n)", arguments.Output);
                                    var line = Console.ReadLine();
                                    if (line == "y") {
                                        break;
                                    } else if (line == "n") {
                                        Console.WriteLine("Operation was canceled.");
                                        return 1;
                                    }
                                    Console.WriteLine("Invalid input text.");
                                }
                            }
                            using (var stream = new System.IO.FileStream(arguments.Output, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) {
                                Model.ToXml(model, stream);
                            }
                        }
                        break;
                    case OperationMode.GenerateModelFromDirectory: {
                            Console.WriteLine("Mode {0}", arguments.Mode);
                            var inputDirectory = new System.IO.DirectoryInfo(arguments.Input);
                            var model = Model.FromDirectory(arguments.Name, inputDirectory.FullName, arguments.SearchPattern, System.IO.SearchOption.AllDirectories, null, arguments.BtrieveLibrary);<commit_msg>fix generator bug<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BtrieveWrapper.Orm.Models.Generator
{
    class Program
    {
        static int Main(string[] args) {
#if DEBUG
#else
            try {
#endif
                Arguments arguments;
                try {
                    arguments = Arguments.Parse(args);
                } catch {
                    throw new ArgumentException();
                }
                foreach (var assemly in arguments.Assemblies) {
                    foreach (var type in assemly.GetTypes()) {
                        if (type.GetInterfaces().Any(i => i == typeof(IModelInitializable))) {
                            var initializable = (IModelInitializable)Activator.CreateInstance(type);
                            initializable.Initialize();
                        }
                    }
                }
                switch (arguments.Mode) {
                    case OperationMode.GenerateModelFromDdf: {
                            Console.WriteLine("Mode {0}", arguments.Mode);
                            var uri = arguments.Uri;
                            if (uri == null) {
                                throw new ArgumentException();
                            }
                            var model = Model.FromDdf(uri.UriHost, uri.UriDbName, uri.UriUser, uri.UriPassword, uri.UriPrompt, null, arguments.BtrieveLibrary);
                            if (arguments.Namespace != null) {
                                model.Namespace = arguments.Namespace;
                            }
                            if (System.IO.File.Exists(arguments.Output) && !arguments.Silent) {
                                for (; ; ) {
                                    Console.WriteLine(@"""{0}"" already exists. Overwrite it? (y/n)", arguments.Output);
                                    var line = Console.ReadLine();
                                    if (line == "y") {
                                        break;
                                    } else if (line == "n") {
                                        Console.WriteLine("Operation was canceled.");
                                        return 1;
                                    }
                                    Console.WriteLine("Invalid input text.");
                                }
                            }
                            using (var stream = new System.IO.FileStream(arguments.Output, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) {
                                Model.ToXml(model, stream);
                            }
                        }
                        break;
                    case OperationMode.GenerateModelFromDirectory: {
                            Console.WriteLine("Mode {0}", arguments.Mode);
                            var inputDirectory = new System.IO.DirectoryInfo(arguments.Input);
                            var model = Model.FromDirectory(arguments.Name, inputDirectory.FullName, arguments.SearchPattern, System.IO.SearchOption.AllDirectories, null, arguments.BtrieveLibrary);
                            if (arguments.Namespace != null) {
                                model.Namespace = arguments.Namespace;
                            }
{'fraction_non_alphanumeric': 0.08717466290373158, 'fraction_numerical': 0.0012543116964565694, 'mean_word_length': 1.046519088867501, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780744', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1306, 'n_words': 273}