Ejemplo n.º 1
0
        public static string LimpaConteudoNome(string texto)
        {
            if (string.IsNullOrEmpty(texto))
            {
                return(string.Empty);
            }

            texto = texto.RemoveAcentuacao()
                    .RemoverDiacritico()
                    .RemoveCaracteresNaoAlfa(true)
                    .ToLower()
                    .Trim();

            texto = Equivalencia.RetiraNumeraisInteligentemente(texto);
            if (string.IsNullOrEmpty(texto))
            {
                return(string.Empty);
            }

            if (texto.Length <= 1)
            {
                return(string.Empty);
            }

            return(texto);
        }
Ejemplo n.º 2
0
        private bool ComparaPrimeiroComSegundo(string valorDoCadastro, string valorEncontradoOcr)
        {
            valorEncontradoOcr = Equivalencia.RetiraNumeraisInteligentemente(valorEncontradoOcr);

            if (string.IsNullOrEmpty(valorDoCadastro) || string.IsNullOrEmpty(valorEncontradoOcr))
            {
                return(false);
            }

            valorDoCadastro = valorDoCadastro
                              .RemoverDiacritico()
                              .RemoveAcentuacao()
                              .ToLower()
                              .Trim();

            valorEncontradoOcr = valorEncontradoOcr
                                 .RemoverDiacritico()
                                 .RemoveAcentuacao()
                                 .RemoveCaracteresNaoAlfa(true)
                                 .ToLower()
                                 .Trim();

            var separador = new[]
            {
                Convert.ToString(' '),
                Environment.NewLine
            };

            var nomesPrimeiroValor = valorDoCadastro
                                     .Split(separador, StringSplitOptions.RemoveEmptyEntries)
                                     .ToList();

            var posicao = valorEncontradoOcr.IndexOf(nomesPrimeiroValor[0]);

            if (posicao > 0)
            {
                valorEncontradoOcr = valorEncontradoOcr.Substring(posicao);
            }

            var nomesSegundoValor = valorEncontradoOcr
                                    .Split(separador, StringSplitOptions.RemoveEmptyEntries).ToList();

            Equivalencia.RemovePalavrasCurtasNoFinal(ref nomesSegundoValor);

            var nomesParaComparacaoPrimeiroValor = (List <string>) this.ObterPrimeiroEUltimoNome(nomesPrimeiroValor);
            var nomesParaComparacaoSegundoValor  = (List <string>) this.ObterPrimeiroEUltimoNome(nomesSegundoValor);

            return(Equivalencia.CompararSequencia(nomesParaComparacaoPrimeiroValor, nomesParaComparacaoSegundoValor));
        }
Ejemplo n.º 3
0
        public bool SaoIguais(string primeiroValor, string segundoValor)
        {
            if (this.ValoresSaoValidos(primeiroValor, segundoValor) == false)
            {
                return(false);
            }

            segundoValor = Equivalencia.RetiraNumeraisInteligentemente(segundoValor);

            var nomesPrimeiroValor = primeiroValor
                                     .RemoverDiacritico()
                                     .RemoveAcentuacao()
                                     .Replace("\n", " ")
                                     .ToLower().Trim();

            var nomesSegundoValor = segundoValor
                                    .RemoverDiacritico()
                                    .RemoveAcentuacao()
                                    .RemoveCaracteresNaoAlfa(true)
                                    .Replace("\n", " ")
                                    .ToLower().Trim();

            var listaNomesPrimeiroValor = nomesPrimeiroValor.Split(' ').ToList();

            var posicao = nomesSegundoValor.IndexOf(listaNomesPrimeiroValor[0]);

            if (posicao > 0)
            {
                nomesSegundoValor = nomesSegundoValor.Substring(posicao);
            }

            List <string> listaNomesSegundoValor = nomesSegundoValor.Split(' ').ToList();

            Equivalencia.RemovePalavrasCurtasNoFinal(ref listaNomesSegundoValor);
            listaNomesPrimeiroValor.RemoveAll(x => x.Equals(string.Empty));
            listaNomesSegundoValor.RemoveAll(x => x.Equals(string.Empty));

            return(Equivalencia.CompararSequencia(listaNomesPrimeiroValor, listaNomesSegundoValor));
        }