Commit 532686a68952eb03dc6ef8995396147dbffdccff
1 parent
9f3d3d77
Exists in
devel
[TranslationServer] Adiciona condição para carregar todo dicionário de uma vez
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
src/LerDicionarios.py
| ... | ... | @@ -51,7 +51,6 @@ class LerDicionarios(object): |
| 51 | 51 | def carregar_dicionarios(self): |
| 52 | 52 | '''Realiza a leitura dos arquivos e atribui à estruturas de dicionários e sets. |
| 53 | 53 | ''' |
| 54 | - print "carregando..." | |
| 55 | 54 | self.carregar_excecoes_plural() |
| 56 | 55 | self.carregar_adverbios_intensidade() |
| 57 | 56 | self.carregar_adverbios_tempo() | ... | ... |
src/PortGlosa.py
| ... | ... | @@ -6,11 +6,15 @@ |
| 6 | 6 | |
| 7 | 7 | #LAViD - Laboratório de Aplicações de Vídeo Digital |
| 8 | 8 | |
| 9 | -import sys | |
| 9 | +import sys, inspect | |
| 10 | 10 | from ThreadTradutor import * |
| 11 | 11 | from LerDicionarios import * |
| 12 | 12 | |
| 13 | 13 | taxas = [] |
| 14 | +dicionario = LerDicionarios() | |
| 15 | +classe_pai = inspect.getframeinfo(inspect.getouterframes(inspect.currentframe())[1][0])[0] | |
| 16 | +if classe_pai == "TranslationServer.py": | |
| 17 | + dicionario.carregar_dicionarios() | |
| 14 | 18 | |
| 15 | 19 | def traduzir(texto, threads=False, taxa_qualidade=False): |
| 16 | 20 | if texto.isspace() or texto == "": |
| ... | ... | @@ -54,10 +58,10 @@ def iniciar_sem_threads(texto, taxa_qualidade): |
| 54 | 58 | return " ".join(saidas) |
| 55 | 59 | |
| 56 | 60 | def quebrar_texto(texto): |
| 61 | + global dicionario | |
| 62 | + | |
| 57 | 63 | if '.' not in texto: |
| 58 | 64 | return [texto] |
| 59 | - | |
| 60 | - dicionario = LerDicionarios() | |
| 61 | 65 | texto_quebrado = texto.split() |
| 62 | 66 | tamanho_texto_quebrado = len(texto_quebrado) |
| 63 | 67 | sentencas = [] | ... | ... |