Commit 35790d862ab873786d4322ce5cf82c0a6d935b94
1 parent
44795715
Exists in
master
and in
1 other branch
Adiciona arquivo de exceções do tratamento de plural
Showing
2 changed files
with
20 additions
and
0 deletions
Show diff stats
src/new/LerDicionarios.py
... | ... | @@ -15,6 +15,7 @@ class LerDicionarios(object): |
15 | 15 | |
16 | 16 | def __init__(self): |
17 | 17 | self.path = self.get_path() |
18 | + self.set_exc_plural = [] | |
18 | 19 | self.dic_adv_intensidade = {} |
19 | 20 | self.set_adv_tempo = [] |
20 | 21 | self.set_art = [] |
... | ... | @@ -33,6 +34,7 @@ class LerDicionarios(object): |
33 | 34 | return expanduser("~") + "/vlibras-translate/data/" |
34 | 35 | |
35 | 36 | def carregar_dicionarios(self): |
37 | + self.carregar_excecoes_plural() | |
36 | 38 | self.carregar_adverbios_intensidade() |
37 | 39 | self.carregar_adverbios_tempo() |
38 | 40 | self.carregar_artigos() |
... | ... | @@ -43,6 +45,19 @@ class LerDicionarios(object): |
43 | 45 | self.carregar_verbos_ligacao() |
44 | 46 | self.carregar_verbos_muda_negacao |
45 | 47 | |
48 | + | |
49 | + def carregar_excecoes_plural(self): | |
50 | + try: | |
51 | + self.file = csv.reader(open(self.path+"excecoesPlural.csv")) | |
52 | + except IOError, (errno, strerror): | |
53 | + print "I/O error(%s): %s" % (errno, strerror) | |
54 | + print "carregar_excecoes_plural" | |
55 | + | |
56 | + rows = [] | |
57 | + for row in self.file: | |
58 | + rows.append(row[0].decode("utf-8")) | |
59 | + self.set_exc_plural = set(rows) | |
60 | + | |
46 | 61 | def carregar_adverbios_intensidade(self): |
47 | 62 | try: |
48 | 63 | self.file = csv.reader(open(self.path+"adverbiosIntensidade.csv"), delimiter=";") |
... | ... | @@ -154,6 +169,9 @@ class LerDicionarios(object): |
154 | 169 | if row[1] != "": |
155 | 170 | self.dic_vb_muda_negacao[row[0].decode("utf-8")] = row[1].decode("utf-8") |
156 | 171 | |
172 | + def has_excecao_plural(self, token): | |
173 | + return token not in self.set_exc_plural | |
174 | + | |
157 | 175 | def has_adverbio_intensidade(self, token): |
158 | 176 | return self.dic_adv_intensidade.has_key(token) |
159 | 177 | ... | ... |