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,10 +388,11 @@ class AplicaRegras(object): | ||
388 | lista_simplificada[it.get_count()][0] = singular | 388 | lista_simplificada[it.get_count()][0] = singular |
389 | 389 | ||
390 | if num: | 390 | if num: |
391 | - try: | 391 | + try: |
392 | return self.converter_extenso(lista_simplificada) | 392 | return self.converter_extenso(lista_simplificada) |
393 | except: | 393 | except: |
394 | pass | 394 | pass |
395 | + | ||
395 | return lista_simplificada | 396 | return lista_simplificada |
396 | 397 | ||
397 | # Alterar uma palavra do plural para o singular | 398 | # Alterar uma palavra do plural para o singular |
@@ -423,7 +424,6 @@ class AplicaRegras(object): | @@ -423,7 +424,6 @@ class AplicaRegras(object): | ||
423 | indices_deletar = [] | 424 | indices_deletar = [] |
424 | count = 0 | 425 | count = 0 |
425 | is_sequence = False | 426 | is_sequence = False |
426 | - | ||
427 | for i in range(0, len(lista)): | 427 | for i in range(0, len(lista)): |
428 | token = lista[i][0] | 428 | token = lista[i][0] |
429 | tag = lista[i][1] | 429 | tag = lista[i][1] |
@@ -437,7 +437,7 @@ class AplicaRegras(object): | @@ -437,7 +437,7 @@ class AplicaRegras(object): | ||
437 | indices_deletar.append(i) # Insiro indice na lista para ser removido depois | 437 | indices_deletar.append(i) # Insiro indice na lista para ser removido depois |
438 | elif (is_sequence): | 438 | elif (is_sequence): |
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 | 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 | indices_deletar.append(i) | 441 | indices_deletar.append(i) |
442 | else: | 442 | else: |
443 | # A sequência foi quebrada, o que significa que selecionamos o extenso do número por completo | 443 | # A sequência foi quebrada, o que significa que selecionamos o extenso do número por completo |