Commit 5c76d64acbb574351dd8616f6417928b3b72ca0f
1 parent
bfb31dae
Exists in
master
and in
1 other branch
Implementa tratamento de plural
Showing
1 changed file
with
29 additions
and
8 deletions
Show diff stats
tradutor/src/py/Simplificador.py
... | ... | @@ -18,7 +18,7 @@ class Simplificador(object): |
18 | 18 | self.__dicWords = {} |
19 | 19 | self.__dic2Gen = {} |
20 | 20 | self.__dicTemVerbs = {} |
21 | - self.executeWorkCSV() | |
21 | + self.executeWorkCSV() | |
22 | 22 | |
23 | 23 | # retira artigos e preposicoes; passa verbos para infinitivo e verificar se há sinonimos |
24 | 24 | def simplificar(self, texto): |
... | ... | @@ -36,12 +36,14 @@ class Simplificador(object): |
36 | 36 | if self.__dicWords.has_key(t) == False: # verifica se nao eh artigo/preposicao |
37 | 37 | wu = w.upper() # deixa o token maiusculo |
38 | 38 | #if t[:2] == "VB": |
39 | + if t[-2:] == "-P": | |
40 | + wu = self.pluralAnalysis(w) | |
39 | 41 | if t == "VB-P" or t == "VB-D" or t == "VB-R": |
40 | 42 | self.__verb = True |
41 | 43 | self.__countVerb += 1 |
42 | 44 | if t[:3] == "ADV": |
43 | 45 | self.__adv = True |
44 | - self.__countAdv += 1 | |
46 | + self.__countAdv += 1 | |
45 | 47 | if self.__dicInf.has_key(wu): # verifica se ha um verbo infinitivo desse token |
46 | 48 | sAux = self.__dicInf[wu] # se sim, adiciona numa string aux |
47 | 49 | if self.__dicSin.has_key(sAux): # verifica se ha um sinonimo para esse verbo infinitivo |
... | ... | @@ -78,14 +80,11 @@ class Simplificador(object): |
78 | 80 | self.__dic2Gen = self.__csv.getDic2Gen() |
79 | 81 | self.__dicTemVerbs = self.__csv.getDicTemVerbs() |
80 | 82 | |
81 | - # converte romano para numero/numero para palavra | |
83 | + # converte romano para numero | |
82 | 84 | def auxConvert(self, t): |
83 | 85 | try: |
84 | - txt = roman_to_int(t) | |
85 | - return extenso(txt).decode("utf-8") | |
86 | + return roman_to_int(t) | |
86 | 87 | except: |
87 | - #if t.isdigit(): | |
88 | - # return extenso(t).decode("utf-8") | |
89 | 88 | return t |
90 | 89 | |
91 | 90 | |
... | ... | @@ -137,4 +136,26 @@ class Simplificador(object): |
137 | 136 | elif (hasPas): |
138 | 137 | lv.append(["PASSADO", "TVB"]) |
139 | 138 | self.it.reset() |
140 | - return lv | |
141 | 139 | \ No newline at end of file |
140 | + return lv | |
141 | + | |
142 | + | |
143 | + def pluralAnalysis(self, word): | |
144 | + | |
145 | + if(word[-3:] == "OES" or word[-2:] == "AES" or word[-2:] == "AOS"): | |
146 | + return word[0:-3]+"AO" | |
147 | + elif(word[-3:] == "RES" or word[-2:] == "ZES" or word[-2:] == "NES"): | |
148 | + return word[0:-2] | |
149 | + elif(word[-3:] == "SES"): | |
150 | + #TODO: Algumas palavras possuem marcações gráficas na raiz singular. Ex: Gás – Gases | |
151 | + return word[0:-2] | |
152 | + elif(word[-2:] == "NS"): | |
153 | + return word[0:-2]+"M" | |
154 | + elif(word[-2:] == "IS"): | |
155 | + #TODO: Substitui por –L se a palavra no singular terminar por –AL, -EL, -OL, -UL | |
156 | + #Substitui por –IL se a palavra no singular terminar por -IL | |
157 | + return word[0:-2] | |
158 | + elif(word[-1] == "S"): | |
159 | + #TODO: Palavras paroxítonas ou proparoxítonas terminadas em S. Ex: lápis, vírus, tênis, ônibus, etc | |
160 | + return word[0:-1] | |
161 | + else: | |
162 | + return word | |
142 | 163 | \ No newline at end of file | ... | ... |