Beispiel #1
0
        private static WordsFlashCards.Domain.Word[] Text2Words(string text)
        {
            var tokenizer = new Tokenizer(text);
            var english   = new EnglishInterpreter(tokenizer);
            var words     = english.Interprete().ToArray();

            return(words);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            var inicio    = DateTime.Now;
            var tokenizer = new Tokenizer(File.ReadAllText("eyecompleto.txt"));
            var english   = new EnglishInterpreter(tokenizer);
            var words     = english.Interprete().ToArray();

            words = words.OrderBy(a => a.Phrases.Count()).ToArray();

            var sb = new StringBuilder();

            sb.AppendLine($"Inicio: {inicio}");
            sb.AppendLine($"Tokens: {tokenizer.Tokens.Count}");
            sb.AppendLine($"Words: {words.Count()}");

            foreach (var w in words)
            {
                sb.AppendLine(w.Text);
                sb.AppendLine($"Frases: {w.Phrases.Count()}");
            }

            var rnd = new Random();

            for (int i = 0; i < 30; i++)
            {
                sb.AppendLine("----------------------------");
                var index = rnd.Next(words.Count());
                var w     = words[index];

                sb.AppendLine(w.Text);
                foreach (var p in w.Phrases)
                {
                    sb.AppendLine(p.Text);
                }
            }

            var fim = DateTime.Now;

            sb.AppendLine($"Fim: {fim}");
            var passou = fim - inicio;

            sb.AppendLine($"Tempo dicionario: {passou}");


            File.WriteAllText("eyeprocessado.txt", sb.ToString());
        }
Beispiel #3
0
        internal void ProcessFolder(string folder)
        {
            ApagarRepetidos(folder);
            var  arquivos   = Directory.GetFiles(folder, "*.txt", SearchOption.AllDirectories);
            var  total      = arquivos.Length;
            var  atual      = 0;
            var  sw         = new Stopwatch();
            long ticksMedio = 0;
            var  parar      = false;

            Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) =>
            {
                parar    = true;
                e.Cancel = true;
            };

            foreach (var file in arquivos)
            {
                atual++;
                if (file.ToLower().Contains(" (1).txt"))
                {
                    File.Delete(file);
                    continue;
                }

                var fileName = Path.GetFileName(file);
                Console.WriteLine($"{DateTime.Now}: {atual:0000}/{total} - {fileName}");

                if (_service.CollectionExists(fileName))
                {
                    continue;
                }

                sw.Restart();
                ITokenizer   tokenizer   = new Tokenizer(File.ReadAllText(file));
                IInterpreter interpreter = new EnglishInterpreter(tokenizer);
                var          words       = interpreter.Interprete();
                var          collection  = new Collection()
                {
                    Description = fileName,
                    Name        = fileName
                };
                Console.WriteLine($"Palavras encontradas {words.Count()}");
                CreateFlashCards(collection, words);
                _service.AddCollection(collection);
                _unityOfWork.Commit();

                sw.Stop();
                if (ticksMedio == 0)
                {
                    ticksMedio += sw.ElapsedTicks;
                }
                ticksMedio += sw.ElapsedTicks;
                ticksMedio /= 2;
                var timesPan      = new TimeSpan(ticksMedio);
                var tempoEstimado = new TimeSpan(ticksMedio * (total - atual));
                var horaFinal     = DateTime.Now.Add(tempoEstimado);
                Console.WriteLine("-----------------------------------");
                Console.WriteLine($"Tempo Médio: {timesPan} |||| Tempo Estimado: {tempoEstimado} |||| Tempo Finalizar: {horaFinal}");
                Console.WriteLine("-----------------------------------");

                if (parar)
                {
                    Console.WriteLine("Parada requisitada");
                    return;
                }
            }
        }