Commit c5584b10fabe8fde724ff929714566943092158e

Authored by Erickson Silva
1 parent a7e823d4
Exists in master and in 1 other branch devel

Adiciona novo dicionario de sinonimos

data/portuguesGlosa.csv
... ... @@ -922,7 +922,7 @@ CONCLUDENTE;ORIGINAL;;X
922 922 GENUÍNO;ORIGINAL;;X
923 923 LEGÍTIMO;ORIGINAL;;X
924 924 OFICIAL;ORIGINAL;;X
925   -1;ORIGINAL;;X
  925 +VERDADEIRO;ORIGINAL;;X
926 926 ESCUTAR;OUVIR;;X
927 927 AUDIÇÃO;OUVIR;;X
928 928 OUVINTE;OUVIR;;X
... ... @@ -1243,8 +1243,8 @@ ARREDORES;VIZINHO;;X
1243 1243 VILA;VIZINHO;;X
1244 1244 VOLTA;VOLTAR;;X
1245 1245 REGRESSAR;VOLTAR;;X
1246   -FALSIDADE;0;;X
1247   -VERDADE;1;;X
  1246 +FALSIDADE;FALSO;;X
  1247 +VERDADE;VERDADEIRO;;X
1248 1248 DUZIA;1 2;;
1249 1249 ANANÁS;ABACAXI;;
1250 1250 ABSTER;ABANDONAR;;
... ... @@ -3960,5 +3960,5 @@ PRAGUEJAR;XINGAR;;
3960 3960 CAÇOAR;ZOMBAR;;
3961 3961 ZOMBETEAR;ZOMBAR;;
3962 3962 ZOO;ZOOLÓGICO;;
3963   -HIPÓCRITA;0;;
  3963 +HIPÓCRITA;FALSO;;
3964 3964 TRANSPORTAR;;;
... ...
src/new/AplicaRegras.py
... ... @@ -17,7 +17,7 @@ class AplicaRegras(object):
17 17 self.__dicionarios = LeitorDicionarios()
18 18  
19 19 # retira artigos e preposicoes; passa verbos para infinitivo e verificar se há sinonimos
20   - def simplificar(self, texto):
  20 + def inicializar(self, texto):
21 21 it = Iterator()
22 22 it.load(texto)
23 23 self.__ts = []
... ... @@ -29,8 +29,21 @@ class AplicaRegras(object):
29 29 token = it.getAtualW()
30 30 tag = it.getAtualT()
31 31 self.__b = False
  32 +
32 33 if self.__dicionarios.hasPalavraIgnorada(tag) == False: # verifica se nao eh artigo/preposicao
33 34  
  35 + #VERIFICA SE É SUBTANTIVO COMUM DOS 2 GENEROS
  36 + if self.__dicionarios.hasSubst2Genero(token):
  37 + #del self.__ts[-1]
  38 + lenTicket = len(it.getAntT())
  39 + if ((self.__dicionarios.hasPalavraIgnorada(it.getAntT())) and (it.getAntT()[lenTicket-1:] == "F") or (it.getAntT()[lenTicket-3:] == "F-P")):
  40 + self.__ts.append(["MULHER ", "2GEN"])
  41 + self.__ts.append([token,tag])
  42 + else:
  43 + self.__ts.append(["HOMEM ", "2GEN"])
  44 + self.__ts.append([token,tag])
  45 + self.__b = True
  46 +
34 47 #VERIFICA SE É ADVERBIO E CONTA A QUANTIDADE
35 48 if tag[:3] == "ADV":
36 49 self.__adv = True
... ... @@ -47,24 +60,8 @@ class AplicaRegras(object):
47 60 #VERIFICA SE É VERBO DE TEMPO E CONTA A QUANTIDADE
48 61 if tag == "VB-P" or tag == "VB-D" or tag == "VB-R":
49 62 self.__verb = True
50   - self.__countVerb += 1
51   -
52   -
53   - #VERIFICA SE É SUBTANTIVO COMUM DOS 2 GENEROS
54   - if self.__dicionarios.hasSubst2Genero(token):
55   - #del self.__ts[-1]
56   - lenTicket = len(it.getAntT())
57   - if ((self.__dicionarios.hasPalavraIgnorada(it.getAntT())) and (it.getAntT()[lenTicket-1:] == "F") or (it.getAntT()[lenTicket-3:] == "F-P")):
58   - self.__ts.append(["MULHER ", "2GEN"])
59   - self.__ts.append([token,tag])
60   - else:
61   - self.__ts.append(["HOMEM ", "2GEN"])
62   - self.__ts.append([token,tag])
63   - self.__b = True
64   -
65   - #VERIFICA SE É PLURAL
66   - #if tag[-2:] == "-P":
67   - # token = self.pluralAnalysis(token)
  63 + self.__countVerb += 1
  64 +
68 65  
69 66 #SE NÃO HOUVE NENHUM ALTERAÇÃO, OU SEJA, NÃO APLICOU NENHUMA REGRA, ADICIONA O TOKEN ORIGINAL
70 67 if self.__b == False: # verifica se nao encontrou nem verbo infinito ou sinonimo
... ... @@ -72,9 +69,10 @@ class AplicaRegras(object):
72 69  
73 70 #SE ENCONTROU VERBO, ENTÃO ANALISA a SENTENCA NOVAMENTE (again?)
74 71 if self.__verb == True:
75   - return self.verbalAnalysis(self.__ts)
  72 + self.__ts = self.verbalAnalysis(self.__ts)
76 73  
77   - return self.__ts
  74 + #VERIFICA SE É PLURAL
  75 + return self.hasPlural(self.__ts)
78 76  
79 77  
80 78 # converte romano para numero
... ... @@ -136,7 +134,17 @@ class AplicaRegras(object):
136 134 return lv
137 135  
138 136  
139   - def pluralAnalysis(self, word):
  137 + def hasPlural(self, lista):
  138 +
  139 + tmp = lista
  140 + for e in tmp:
  141 + if e[1][-2:] == "-P":
  142 + e[0] = analisarPlural(e[0])
  143 +
  144 + return tmp
  145 +
  146 +
  147 + def analisarPlural(self, word):
140 148  
141 149 if(word[-3:] == "OES" or word[-2:] == "AES" or word[-2:] == "AOS"):
142 150 return word[0:-3]+"AO"
... ...
src/new/LeitorDicionarios.py
... ... @@ -6,7 +6,8 @@
6 6  
7 7 #LAViD - Laboratório de Aplicações de Vídeo Digital
8 8  
9   -import os, csv, sys
  9 +from os.path import expanduser
  10 +import csv
10 11  
11 12 class LeitorDicionarios(object):
12 13 #_iInstance = None
... ... @@ -29,7 +30,7 @@ class LeitorDicionarios(object):
29 30  
30 31 # Define e inicializa os atributos
31 32 def __init__(self):
32   - self.__path = "/home/erickson/vlibras-translate/data/"
  33 + self.__path = expanduser("~") + "/vlibras-translate/data/"
33 34 self.__dicInf = {}
34 35 self.__dicSin = {}
35 36 self.__dicWords = {}
... ...
src/new/Tradutor.py
... ... @@ -10,8 +10,8 @@ import alexp
10 10 from AplicaSinonimos import *
11 11 from AplicaRegras import *
12 12  
13   -sin = AplicaSinonimos()
14   -reg = AplicaRegras()
  13 +aplicSinonimos = AplicaSinonimos()
  14 +aplicRegras = AplicaRegras()
15 15  
16 16  
17 17 def iniciarTraducao(texto):
... ... @@ -36,10 +36,10 @@ def gerarAnalise(sentenca):
36 36  
37 37  
38 38 def analiseMorfologica(sentenca):
39   - proc = reg.simplificar(sentenca)
40   - return sin.sinonimosMorfologico(proc)
  39 + proc = aplicRegras.inicializar(sentenca)
  40 + return aplicSinonimos.sinonimosMorfologico(proc)
41 41  
42 42  
43 43 def analiseSintatica(sentenca):
44   - analise = sin.sinonimosSintatico(sentenca)
  44 + analise = aplicSinonimos.sinonimosSintatico(sentenca)
45 45 return analise
46 46 \ No newline at end of file
... ...