Commit 537d95fbc7c1f240e6b3e57767c5f3a99d2400f8
1 parent
2c6cd32d
Exists in
master
and in
1 other branch
Corrige tratamento de plural
Showing
1 changed file
with
12 additions
and
7 deletions
Show diff stats
src/AplicaRegras.py
... | ... | @@ -417,24 +417,29 @@ class AplicaRegras(object): |
417 | 417 | def analisar_plural(self, token): |
418 | 418 | '''Altera uma palavra do plural para o singular de acordo com o final da mesma. |
419 | 419 | ''' |
420 | - if(token[-3:] == "ões".decode('utf-8') or token[-2:] == "ães".decode('utf-8') or token[-2:] == "ãos".decode('utf-8')): | |
421 | - return token[0:-3]+"ão".decode('utf-8') | |
422 | - elif(token[-3:] == "res" or token[-2:] == "zes" or token[-2:] == "nes"): | |
420 | + vogais = ['a','e','i','o','u'] | |
421 | + if(token[-3:] == "ões".decode('utf-8') or token[-3:] == "ães".decode('utf-8') or token[-3:] == "ãos".decode('utf-8')): | |
422 | + return token[:-3]+"ão".decode('utf-8') | |
423 | + elif(token[-3:] == "res" or token[-3:] == "zes" or token[-3:] == "nes"): | |
424 | + if token[-4] not in vogais: | |
425 | + return token[:-1] | |
423 | 426 | return token[0:-2] |
424 | 427 | elif(token[-3:] == "ses"): |
425 | 428 | #TODO: Algumas palavras possuem marcações gráficas na raiz singular. Ex: Gás – Gases |
426 | - return token[0:-2] | |
429 | + if token[-4] not in vogais: | |
430 | + return token[:-1] | |
431 | + return token[:-2] | |
427 | 432 | elif(token[-2:] == "ns"): |
428 | 433 | return token[0:-2]+"m" |
429 | 434 | elif(token[-3:] == "eis"): |
430 | - return token[0:-3]+"il" | |
435 | + return token[:-3]+"il" | |
431 | 436 | elif(token[-2:] == "is"): |
432 | 437 | if(token[-3] == "a" or token[-3] == "e" or token[-3] == "o" or token[-3] == "u"): |
433 | - return token[0:-2]+"l" | |
438 | + return token[:-2]+"l" | |
434 | 439 | return token |
435 | 440 | elif(token[-1] == "s"): |
436 | 441 | #TODO: Palavras paroxítonas ou proparoxítonas terminadas em S. Ex: lápis, vírus, tagênis, ônibus, etc |
437 | - return token[0:-1] | |
442 | + return token[:-1] | |
438 | 443 | else: |
439 | 444 | return token |
440 | 445 | ... | ... |