Commit 622366b7432b67b67c9db81466d2c2735a96c12b
1 parent
6513b74b
Exists in
master
and in
1 other branch
Codifica dados dos dicionários para UTF-8
Showing
2 changed files
with
14 additions
and
7 deletions
Show diff stats
src/new/LerDicionarios.py
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | #LAViD - Laboratório de Aplicações de Vídeo Digital |
8 | 8 | |
9 | 9 | from os.path import expanduser |
10 | +from os import environ | |
10 | 11 | import csv |
11 | 12 | import platform |
12 | 13 | |
... | ... | @@ -28,7 +29,7 @@ class LerDicionarios(object): |
28 | 29 | |
29 | 30 | def get_path(self): |
30 | 31 | if platform.system() == 'Windows': |
31 | - return expanduser("~") + "\vlibras-translate\data\" | |
32 | + return os.environ.get("HOMEDRIVE") + "\\vlibras-libs\vlibras-translate\data\" | |
32 | 33 | return expanduser("~") + "/vlibras-translate/data/" |
33 | 34 | |
34 | 35 | def carregar_dicionarios(self): |
... | ... | @@ -98,7 +99,10 @@ class LerDicionarios(object): |
98 | 99 | |
99 | 100 | for row in self.file: |
100 | 101 | if row[1] != "": |
101 | - self.dic_sin[row[0].decode("utf-8")] = row[1].decode("utf-8") | |
102 | + try: | |
103 | + self.dic_sin[row[0].decode("utf-8")] = row[1].decode("utf-8") | |
104 | + except UnicodeDecodeError: | |
105 | + self.dic_sin[row[0].decode('iso8859-1').encode('utf-8').decode('utf-8')] = row[1].decode('iso8859-1').encode('utf-8').decode('utf-8') | |
102 | 106 | |
103 | 107 | def carregar_subs_2_generos(self): |
104 | 108 | try: |
... | ... | @@ -109,7 +113,7 @@ class LerDicionarios(object): |
109 | 113 | |
110 | 114 | rows = [] |
111 | 115 | for row in self.file: |
112 | - rows.append(row[0].decode("utf-8")) | |
116 | + rows.append(row[0].decode('iso8859-1').encode('utf-8').decode('utf-8')) | |
113 | 117 | self.set_sb_2_gen = set(rows) |
114 | 118 | |
115 | 119 | def carregar_verbos_infinitivo(self): |
... | ... | @@ -121,7 +125,10 @@ class LerDicionarios(object): |
121 | 125 | |
122 | 126 | for row in self.file: |
123 | 127 | if row[1] != "": |
124 | - self.dic_vb_infinitivo[row[0].decode("utf-8")] = row[1].decode("utf-8") | |
128 | + try: | |
129 | + self.dic_vb_infinitivo[row[0].decode("utf-8")] = row[1].decode("utf-8") | |
130 | + except UnicodeDecodeError: | |
131 | + self.dic_vb_infinitivo[row[0].decode('iso8859-1').encode('utf-8').decode('utf-8')] = row[1].decode('iso8859-1').encode('utf-8').decode('utf-8') | |
125 | 132 | |
126 | 133 | def carregar_verbos_ligacao(self): |
127 | 134 | try: | ... | ... |
src/new/PortGlosa.py
... | ... | @@ -8,14 +8,14 @@ |
8 | 8 | |
9 | 9 | from TraduzSentencas import * |
10 | 10 | |
11 | -def traduz(texto): | |
11 | +def traduzir(texto): | |
12 | 12 | glosa = iniciar_traducao(texto) |
13 | 13 | if glosa: |
14 | 14 | return glosa |
15 | 15 | return "selecione_texto" |
16 | 16 | |
17 | 17 | def iniciar_traducao(texto): |
18 | - texto_quebrado = quebrar_texto(texto.lower()) | |
18 | + texto_quebrado = quebrar_texto(texto) | |
19 | 19 | num_threads = len(texto_quebrado) |
20 | 20 | texto_traduzido = [] |
21 | 21 | threads = [] |
... | ... | @@ -45,6 +45,6 @@ def quebrar_texto(texto): |
45 | 45 | sentencas.append(texto) |
46 | 46 | return sentencas |
47 | 47 | |
48 | -def help(): | |
48 | +def ajuda(): | |
49 | 49 | #TODO: Adicionar um pequeno tuto aqui |
50 | 50 | print "Help" |
51 | 51 | \ No newline at end of file | ... | ... |