Commit 816cb7e5fc4c26d4bf5f5a6a60758d543dd55844
1 parent
b2c3a09b
Exists in
devel
Remove logging no TraduzSentencas
Showing
1 changed file
with
2 additions
and
53 deletions
Show diff stats
src/TraduzSentencas.py
... | ... | @@ -9,13 +9,7 @@ |
9 | 9 | from ClassificaSentencas import * |
10 | 10 | from AplicaRegras import * |
11 | 11 | from AplicaSinonimos import * |
12 | -import logging | |
13 | -import logging.handlers | |
14 | -import traceback | |
15 | -import subprocess | |
16 | -import re, string | |
17 | -import getopt | |
18 | -import sys | |
12 | +import subprocess, re, string, sys | |
19 | 13 | |
20 | 14 | class TraduzSentencas(object): |
21 | 15 | '''Realiza a tradução do texto em português para glosa |
... | ... | @@ -27,7 +21,6 @@ class TraduzSentencas(object): |
27 | 21 | self.classificador = ClassificaSentencas() |
28 | 22 | self.aplic_regras = AplicaRegras() |
29 | 23 | self.aplic_sin = AplicaSinonimos() |
30 | - self.check_level() | |
31 | 24 | |
32 | 25 | def iniciar_traducao(self, sentenca, taxa=False): |
33 | 26 | '''Metódo responsável por executar todos componentes necessários para a geração da glosa. |
... | ... | @@ -36,7 +29,6 @@ class TraduzSentencas(object): |
36 | 29 | has_sintatica = True |
37 | 30 | analise_sintatica = self.classificador.iniciar_classificacao(sentenca) |
38 | 31 | except Exception as ex: |
39 | - self.salvar_log(str(traceback.format_exc())) | |
40 | 32 | analise_sintatica = None |
41 | 33 | has_sintatica = False |
42 | 34 | |
... | ... | @@ -61,49 +53,6 @@ class TraduzSentencas(object): |
61 | 53 | return texto_com_sinonimos.upper().encode('utf-8') |
62 | 54 | return "TEXTO ERRADO ESCOLHER OUTRO" |
63 | 55 | |
64 | - | |
65 | - def salvar_log(self, erro): | |
66 | - '''Salva traceback de uma excessão do analisador sintático | |
67 | - ''' | |
68 | - logger = logging.getLogger('error-feedback') | |
69 | - logger.propagate = False | |
70 | - logger.error(erro) | |
71 | - | |
72 | - def criar_logger_error(self): | |
73 | - error_log = logging.getLogger('error-feedback') | |
74 | - error_log.setLevel(logging.ERROR) | |
75 | - ##print os.path.dirname(__file__) -- Salvar no direitorio do arquivo .py? | |
76 | - error_handler = logging.handlers.RotatingFileHandler('/var/tmp/vlibras-translate.log', maxBytes=1024, backupCount=5) | |
77 | - formatter = logging.Formatter('%(asctime)s - %(levelname)s:\n\n%(message)s\n\n\n##############################################\n\n') | |
78 | - error_handler.setFormatter(formatter) | |
79 | - error_log.addHandler(error_handler) | |
80 | - | |
81 | - def check_level(self): | |
82 | - try: | |
83 | - for opt in sys.argv[1:]: | |
84 | - if "--log" in opt: | |
85 | - self.set_level(opt[6:]) | |
86 | - return | |
87 | - except: | |
88 | - pass | |
89 | - self.desativar_logging() | |
90 | - | |
91 | - def set_level(self, level): | |
92 | - numeric_level = getattr(logging, level.upper(), None) | |
93 | - if not isinstance(numeric_level, int): | |
94 | - raise ValueError('Nível de log inválido: %s' % level) | |
95 | - logging.disable(logging.NOTSET) | |
96 | - logging.getLogger().setLevel(numeric_level) | |
97 | - if numeric_level == 40 or numeric_level == 10: | |
98 | - self.criar_logger_error() | |
99 | - | |
100 | - def desativar_logging(self): | |
101 | - logging.disable(logging.DEBUG) | |
102 | - logging.disable(logging.INFO) | |
103 | - logging.disable(logging.WARNING) | |
104 | - logging.disable(logging.ERROR) | |
105 | - logging.disable(logging.CRITICAL) | |
106 | - | |
107 | 56 | def gerar_metrica_qualidade(self, lista): |
108 | 57 | #TODO: resolver path do arquivo |
109 | 58 | arqSinais = open("sinais.txt", "r").read().split() |
... | ... | @@ -115,4 +64,4 @@ class TraduzSentencas(object): |
115 | 64 | else: |
116 | 65 | if x[1] == "NPR": |
117 | 66 | quantSinaisTotal-=1 |
118 | 67 | - return float(quantSinaisEncontradas)/quantSinaisTotal |
68 | + return float(quantSinaisEncontradas)/quantSinaisTotal | |
119 | 69 | \ No newline at end of file | ... | ... |