def main(): lista_tts = getAllTweets() for tt in lista_tts: # recebe tweet cru e transforma em minusculo texto = tt.text.lower() print(texto) tt.hashtag = 1 if '#foracunha' in texto else 2 # retira pontuacao, mencoes, hashtags e (kkkkkk, hahaha, hehehe, affs) retira acentos e espacos nas extremidades texto = re.sub(r'\B[@#]\S+\b|[^a-zA-Z]|k+|(ha|he)\S{2,}|a+f+(\s|$)', ' ', unidecode(texto)).strip() # remove espacos repetidos entre palavras texto = re.sub(r'\s+', ' ', texto) t = texto.split(' ') # remove stopwords for palavra in t[:]: if palavra in stop_words: t.remove(palavra) # junta lista de palavras e as separa por espaco t = ' '.join(t) print('final:', t) # atualiza tweet na base de dados try: if t != '': tt.text = t else: tt.delete() except CommitException: pass
def main(): foracunha = open('../foracunha.dl', 'w') ficacunha = open('../ficacunha.dl', 'w') foracunha.write('DL n=5\nformat = edgelist1\nlabels embedded:\ndata:\n') ficacunha.write('DL n=5\nformat = edgelist1\nlabels embedded:\ndata:\n') lista_tts = getAllTweets() for tt in lista_tts: lista_palavras = tt.text.split() palavra = lista_palavras.pop() if lista_palavras != None: for p in lista_palavras: linha = '{0} {1}\n'.format(palavra, p) print(linha) if tt.hashtag == 1: foracunha.write(linha) else: ficacunha.write(linha) foracunha.close() ficacunha.close()