Commit b5fba479765092a16724ec8288add8c3f2e9e0ce

Authored by Erickson Silva
1 parent 927ebcc7
Exists in master and in 1 other branch devel

Adiciona traceback no logging

src/AplicaRegras.py
@@ -13,7 +13,6 @@ from os.path import expanduser @@ -13,7 +13,6 @@ from os.path import expanduser
13 from collections import deque 13 from collections import deque
14 from LerDicionarios import * 14 from LerDicionarios import *
15 from Iterator import * 15 from Iterator import *
16 -from StringAux import *  
17 from ConverteExtenso import * 16 from ConverteExtenso import *
18 from nltk_tgrep import tgrep_positions, tgrep_nodes 17 from nltk_tgrep import tgrep_positions, tgrep_nodes
19 from nltk import ParentedTree, Tree, draw 18 from nltk import ParentedTree, Tree, draw
src/PortGlosa.py
@@ -9,10 +9,14 @@ @@ -9,10 +9,14 @@
9 from TraduzSentencas import * 9 from TraduzSentencas import *
10 10
11 def traduzir(texto): 11 def traduzir(texto):
  12 + if texto.isspace() or texto == "":
  13 + return "SELECIONE UM TEXTO"
  14 +
12 glosa = iniciar_traducao(texto) 15 glosa = iniciar_traducao(texto)
  16 +
13 if glosa: 17 if glosa:
14 return glosa 18 return glosa
15 - return "selecione_texto" 19 + return "HOUVE UM ERRO. TENTE NOVAMENTE"
16 20
17 def iniciar_traducao(texto): 21 def iniciar_traducao(texto):
18 texto_quebrado = quebrar_texto(texto) 22 texto_quebrado = quebrar_texto(texto)
src/TraduzSentencas.py
@@ -11,6 +11,7 @@ import alexp @@ -11,6 +11,7 @@ import alexp
11 from AplicaSinonimos import * 11 from AplicaSinonimos import *
12 from AplicaRegras import * 12 from AplicaRegras import *
13 import logging 13 import logging
  14 +import traceback
14 15
15 class TraduzSentencas(Thread): 16 class TraduzSentencas(Thread):
16 17
@@ -21,7 +22,7 @@ class TraduzSentencas(Thread): @@ -21,7 +22,7 @@ class TraduzSentencas(Thread):
21 self.aplic_sinonimos = AplicaSinonimos() 22 self.aplic_sinonimos = AplicaSinonimos()
22 self.aplic_regras = AplicaRegras() 23 self.aplic_regras = AplicaRegras()
23 logging.basicConfig(filename='translate.log', 24 logging.basicConfig(filename='translate.log',
24 - format='%(asctime)s - %(levelname)s:\n%(message)s\n\n\n##############################################\n\n', 25 + format='%(asctime)s - %(levelname)s:\n\n%(message)s\n\n\n##############################################\n\n',
25 level=logging.ERROR) 26 level=logging.ERROR)
26 27
27 28
@@ -29,7 +30,7 @@ class TraduzSentencas(Thread): @@ -29,7 +30,7 @@ class TraduzSentencas(Thread):
29 try: 30 try:
30 analise_sintatica = alexp.run(self.sentenca) 31 analise_sintatica = alexp.run(self.sentenca)
31 except Exception as ex: 32 except Exception as ex:
32 - self.salvar_log(str(ex)) 33 + self.salvar_log(str(traceback.format_exc()))
33 analise_sintatica = None 34 analise_sintatica = None
34 35
35 analise_morfologica = alexp.getAnaliseMorfologica() 36 analise_morfologica = alexp.getAnaliseMorfologica()