Commit 6c4ad994c358f7d33c4f86fef4047ab7591ca48d
1 parent
5e3d636c
Exists in
master
and in
1 other branch
Corrige conversor de número por extenso
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
src/AplicaRegras.py
... | ... | @@ -388,10 +388,11 @@ class AplicaRegras(object): |
388 | 388 | lista_simplificada[it.get_count()][0] = singular |
389 | 389 | |
390 | 390 | if num: |
391 | - try: | |
391 | + try: | |
392 | 392 | return self.converter_extenso(lista_simplificada) |
393 | 393 | except: |
394 | 394 | pass |
395 | + | |
395 | 396 | return lista_simplificada |
396 | 397 | |
397 | 398 | # Alterar uma palavra do plural para o singular |
... | ... | @@ -423,7 +424,6 @@ class AplicaRegras(object): |
423 | 424 | indices_deletar = [] |
424 | 425 | count = 0 |
425 | 426 | is_sequence = False |
426 | - | |
427 | 427 | for i in range(0, len(lista)): |
428 | 428 | token = lista[i][0] |
429 | 429 | tag = lista[i][1] |
... | ... | @@ -437,7 +437,7 @@ class AplicaRegras(object): |
437 | 437 | indices_deletar.append(i) # Insiro indice na lista para ser removido depois |
438 | 438 | elif (is_sequence): |
439 | 439 | # Se o token anterior e o próximo foram classificados como número, e o token atual como conjunção, significa que podemos remove-lo |
440 | - if ((lista[i-1][1] == "NUM") and (lista[i+1][1] == "NUM") and (tag == "CONJ")): | |
440 | + if ((i+1 < len(lista)) and (lista[i-1][1] == "NUM") and (lista[i+1][1] == "NUM") and (tag == "CONJ")): | |
441 | 441 | indices_deletar.append(i) |
442 | 442 | else: |
443 | 443 | # A sequência foi quebrada, o que significa que selecionamos o extenso do número por completo | ... | ... |