Skip to content

Commit d9a6331

Browse files
committed
Versão final do Script
1 parent 74d4094 commit d9a6331

File tree

2 files changed

+55
-38
lines changed

2 files changed

+55
-38
lines changed

getVerbos.py

+39-38
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from email.mime.text import MIMEText
1212
from unicodedata import normalize
1313

14-
#'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'
15-
arrayLetras = ('z')
14+
#
15+
# Executadas - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w'
16+
arrayLetras = ('x','y','z')
1617

1718
def enviaEmail(texto):
1819
sender = '[email protected]'
@@ -41,7 +42,6 @@ def remover_acentos(txt, codif='utf-8'):
4142
return normalize('NFKD', txt.decode(codif)).encode('ASCII','ignore')
4243

4344
def usarReplace(palavra):
44-
#palavra = palavra.replace('não', '').replace('para ', '').replace('eu','').replace('voc','').replace(' ele/ela','').replace('vocs','').replace('tu','').replace('vs','').replace('no','').replace('ns','').replace('eles/elas','').replace('ele/ela','').replace(' s','').replace(' ','').replace('ês', '').replace('vós', '').replace('nós', '')
4545
pattern = re.compile('[ / ]([ a-zà-ú]+)$')
4646
palavra_new = re.sub(pattern, '', palavra)
4747
pattern = re.compile('(ê)$')
@@ -149,41 +149,42 @@ def getVerbosConjugados(listaVerbos):
149149
soup = getConvertObjectSoup('http://www.conjuga-me.net/verbo-'+verbo, 'iso8859-1')
150150

151151
for s in soup.find_all('td', attrs = { 'class' : 'output'}):
152-
if s.text and s.text != None and s.text != '' and s.text != '\t' and s.text != '\n' and s.text != ' ' and s.text != '–' and s.text != ' - ':
153-
palavra = usarReplace(s.text.encode('utf-8'))
154-
cursor.execute('select id_verbos from verbos where nome = "'+ verbo.strip() +'"')
155-
if palavra and re.search('[a-zA-Z]', palavra):
156-
id_verbo = cursor.fetchone()
157-
if count[0] == 10 and count_valida in valida:
158-
print 'id_verbo: '+ str(id_verbo[0]) + ' - ' + palavra
159-
sql = 'insert into conjulgacao_verbal (nome_conjulgacao, id_tempo_verbal, id_verbo) value (%s, %s, %s)'
160-
db.commit()
161-
cursor.execute(sql, (palavra, count[num], id_verbo[0]))
162-
if count[0] != 10:
163-
print 'id_verbo: '+ str(id_verbo[0]) + ' - ' + palavra
164-
sql = 'insert into conjulgacao_verbal (nome_conjulgacao, id_tempo_verbal, id_verbo) value (%s, %s, %s)'
165-
db.commit()
166-
cursor.execute(sql, (palavra, count[num], id_verbo[0]))
167-
168-
169-
num += 1
170-
if num == 3:
171-
num = 0
172-
contador += 1
173-
if contador == 18:
174-
count = [4, 6, 5]
175-
if contador == 36:
176-
count = [7, 9, 8]
177-
if contador == 54:
178-
count = [10, 10, 10]
179-
if contador == 72:
180-
contador = 0
181-
count = [1, 3, 2]
182-
183-
if count[0] == 10 and count[1] == 10 and count[2] == 10:
184-
count_valida += 1
185-
if count_valida == 18:
186-
count_valida = 0
152+
#if s.text and s.text != None and s.text != '' and s.text != '\t' and s.text != '\n' and s.text != ' ' and s.text != '–' and s.text != ' - ':
153+
palavra = usarReplace(s.text.encode('utf-8'))
154+
cursor.execute('select id_verbos from verbos where nome = "'+ verbo.strip() +'"')
155+
#if palavra and re.search('[a-zA-Z]', palavra):
156+
#if re.search('[a-zA-Z\s]', palavra):
157+
id_verbo = cursor.fetchone()
158+
if count[0] == 10 and count_valida in valida:
159+
print 'id_verbo: '+ str(id_verbo[0]) + ' - ' + palavra
160+
sql = 'insert into conjulgacao_verbal (nome_conjulgacao, id_tempo_verbal, id_verbo) value (%s, %s, %s)'
161+
db.commit()
162+
cursor.execute(sql, (palavra, count[num], id_verbo[0]))
163+
if count[0] != 10:
164+
print 'id_verbo: '+ str(id_verbo[0]) + ' - ' + palavra
165+
sql = 'insert into conjulgacao_verbal (nome_conjulgacao, id_tempo_verbal, id_verbo) value (%s, %s, %s)'
166+
db.commit()
167+
cursor.execute(sql, (palavra, count[num], id_verbo[0]))
168+
169+
170+
num += 1
171+
if num == 3:
172+
num = 0
173+
contador += 1
174+
if contador == 18:
175+
count = [4, 6, 5]
176+
if contador == 36:
177+
count = [7, 9, 8]
178+
if contador == 54:
179+
count = [10, 10, 10]
180+
if contador == 72:
181+
contador = 0
182+
count = [1, 3, 2]
183+
184+
if count[0] == 10 and count[1] == 10 and count[2] == 10:
185+
count_valida += 1
186+
if count_valida == 18:
187+
count_valida = 0
187188

188189

189190
cursor.close()

verbos.txt

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
xadrezar
2+
xerardizar
3+
xerografar
4+
xilogravar
5+
xaropar
6+
xeretar
7+
xeroxar
8+
xingar
9+
xaropear
10+
xeretear
11+
xetrar
12+
xumbergar
13+
xavecar
14+
xerocar
15+
xilografar
16+
xumbregar
117
zabumbar
218
zavar
319
zinir

0 commit comments

Comments
 (0)