Commit 5d7f200def8109148a1684e7262e78f2942d7347
1 parent
537d95fb
Exists in
master
and in
1 other branch
Replace em caracteres graficos (hífen, aspas) normalmente encontrados em documentos PDF
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
src/PortGlosa.py
@@ -18,7 +18,8 @@ taxas = [] | @@ -18,7 +18,8 @@ taxas = [] | ||
18 | 18 | ||
19 | def traduzir(texto, log=None, threads=False, taxa_qualidade=False): | 19 | def traduzir(texto, log=None, threads=False, taxa_qualidade=False): |
20 | tradutor.set_level(log) if log != None else tradutor.desativar_logging() | 20 | tradutor.set_level(log) if log != None else tradutor.desativar_logging() |
21 | - if texto.isspace() or texto == "" or not checar_idioma(texto): | 21 | + if texto.isspace() or texto == "": |
22 | + #or not checar_idioma(texto): | ||
22 | return "ESCOLHER TEXTO CERTO" | 23 | return "ESCOLHER TEXTO CERTO" |
23 | 24 | ||
24 | elif threads: | 25 | elif threads: |
@@ -71,7 +72,9 @@ def quebrar_texto(texto): | @@ -71,7 +72,9 @@ def quebrar_texto(texto): | ||
71 | lista_texto.append(texto_quebrado[i]) | 72 | lista_texto.append(texto_quebrado[i]) |
72 | if '.' in texto_quebrado[i]: | 73 | if '.' in texto_quebrado[i]: |
73 | if not dicionario.has_pron_tratam(texto_quebrado[i].lower()) and i < tamanho_texto_quebrado-1 and texto_quebrado[i+1][0].isupper(): | 74 | if not dicionario.has_pron_tratam(texto_quebrado[i].lower()) and i < tamanho_texto_quebrado-1 and texto_quebrado[i+1][0].isupper(): |
74 | - sentenca = " ".join(lista_texto)[:-1]+"." | 75 | + sentenca = " ".join(lista_texto) |
76 | + if not sentenca[-1].isdigit(): | ||
77 | + sentenca = sentenca[:-1]+"." | ||
75 | sentencas.append(sentenca) | 78 | sentencas.append(sentenca) |
76 | lista_texto = [] | 79 | lista_texto = [] |
77 | continue | 80 | continue |
src/alexp.py
@@ -40,7 +40,8 @@ sleep_times=[0.1,0.2] | @@ -40,7 +40,8 @@ sleep_times=[0.1,0.2] | ||
40 | def toqueniza(s): | 40 | def toqueniza(s): |
41 | """Decodifica string utilizando utf-8, retornando uma lista de tokens em unicode. | 41 | """Decodifica string utilizando utf-8, retornando uma lista de tokens em unicode. |
42 | """ | 42 | """ |
43 | - decodificada=s.decode("utf-8") | 43 | + regex = re.compile('[%s]' % re.escape('“”')) |
44 | + decodificada=regex.sub('-',s.replace("–", "-")).decode("utf-8") | ||
44 | return AnotaCorpus.TOK_PORT.tokenize(decodificada) | 45 | return AnotaCorpus.TOK_PORT.tokenize(decodificada) |
45 | 46 | ||
46 | def getAnaliseMorfologica(): | 47 | def getAnaliseMorfologica(): |