diff --git a/tradutor/src/py/Simplificador.py b/tradutor/src/py/Simplificador.py index edb1d71..c5711c1 100644 --- a/tradutor/src/py/Simplificador.py +++ b/tradutor/src/py/Simplificador.py @@ -18,7 +18,7 @@ class Simplificador(object): self.__dicWords = {} self.__dic2Gen = {} self.__dicTemVerbs = {} - self.executeWorkCSV() + self.executeWorkCSV() # retira artigos e preposicoes; passa verbos para infinitivo e verificar se há sinonimos def simplificar(self, texto): @@ -36,12 +36,14 @@ class Simplificador(object): if self.__dicWords.has_key(t) == False: # verifica se nao eh artigo/preposicao wu = w.upper() # deixa o token maiusculo #if t[:2] == "VB": + if t[-2:] == "-P": + wu = self.pluralAnalysis(w) if t == "VB-P" or t == "VB-D" or t == "VB-R": self.__verb = True self.__countVerb += 1 if t[:3] == "ADV": self.__adv = True - self.__countAdv += 1 + self.__countAdv += 1 if self.__dicInf.has_key(wu): # verifica se ha um verbo infinitivo desse token sAux = self.__dicInf[wu] # se sim, adiciona numa string aux if self.__dicSin.has_key(sAux): # verifica se ha um sinonimo para esse verbo infinitivo @@ -78,14 +80,11 @@ class Simplificador(object): self.__dic2Gen = self.__csv.getDic2Gen() self.__dicTemVerbs = self.__csv.getDicTemVerbs() - # converte romano para numero/numero para palavra + # converte romano para numero def auxConvert(self, t): try: - txt = roman_to_int(t) - return extenso(txt).decode("utf-8") + return roman_to_int(t) except: - #if t.isdigit(): - # return extenso(t).decode("utf-8") return t @@ -137,4 +136,26 @@ class Simplificador(object): elif (hasPas): lv.append(["PASSADO", "TVB"]) self.it.reset() - return lv \ No newline at end of file + return lv + + + def pluralAnalysis(self, word): + + if(word[-3:] == "OES" or word[-2:] == "AES" or word[-2:] == "AOS"): + return word[0:-3]+"AO" + elif(word[-3:] == "RES" or word[-2:] == "ZES" or word[-2:] == "NES"): + return word[0:-2] + elif(word[-3:] == "SES"): + #TODO: Algumas palavras possuem marcações gráficas na raiz singular. Ex: Gás – Gases + return word[0:-2] + elif(word[-2:] == "NS"): + return word[0:-2]+"M" + elif(word[-2:] == "IS"): + #TODO: Substitui por –L se a palavra no singular terminar por –AL, -EL, -OL, -UL + #Substitui por –IL se a palavra no singular terminar por -IL + return word[0:-2] + elif(word[-1] == "S"): + #TODO: Palavras paroxítonas ou proparoxítonas terminadas em S. Ex: lápis, vírus, tênis, ônibus, etc + return word[0:-1] + else: + return word \ No newline at end of file -- libgit2 0.21.2