-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcallfunc.py
182 lines (154 loc) · 6.02 KB
/
callfunc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
__author__ = "Ahirton Lopes"
__copyright__ = "Copyright 2015/2016, Mackenzie University"
__credits__ = ["Ahirton Lopes", "Rodrigo Pasti", "Leandro de Castro"]
__license__ = "None"
__version__ = "1.0"
__maintainer__ = "Ahirton Lopes"
__email__ = "[email protected]"
__status__ = "Beta"
"""
"""
'''
-----------------------------------------------------------------------------------------------------------------------
LEITURA DE TWEETS CONTIDOS EM ARQUIVO CSV E EXTRACAO DE META-ATRIBUTOS TEXTUAIS
-----------------------------------------------------------------------------------------------------------------------
"""
'''
#Passos:
#--------------------------------------------------------------------------------------------------------
# Devem ser utilizados dois metodos para a viabilizacao dos testes de classificacao
#--------------------------------------------------------------------------------------------------------
#(1) Metodo 1 - Coleta automatica tweet a tweet por arquivos .csv
#(2) Metodo 2 - Coleta automatica de tweets concatenados por arquivos .csv
#--------------------------------------------------------------------------------------------------------
'''
import sys
from extract_meta_attributes import MetaAttributes
import csv
import text_processing as tp
'''
-----------------------------------------------------------------------------------------------------------------------
(1) MECANISMO DE COLETA AUTOMATICA DE TWEETS POR ARQUIVO CSV - METODO 1 (TWEET A TWEET)
-----------------------------------------------------------------------------------------------------------------------
'''
#Coleta automatica tweet a tweet via arquivos .csv e utilizacao do extrator de meta-atributos
#with open("cidinhacampos_tweets.csv", "rb") as f:
# reader = csv.reader(f, delimiter="\t")
# for i, line in enumerate(reader):
# print 'tweet [{}] = {}'.format(i, line)
# tweetatweet = MetaAttributes('{}'.format(line))
# print tweetatweet.all_meta_attributes
# sys.stdout = open("logtweetatweetcidihacampos.txt", "a")
'''
-----------------------------------------------------------------------------------------------------------------------
(2) MECANISMO DE COLETA AUTOMATICA DE TWEETS POR ARQUIVO CSV - METODO 2 (CONCATENADOS)
-----------------------------------------------------------------------------------------------------------------------
'''
# Concatenacao dos tweets de cada linha em um so texto
#with open("[CM30] realwbonner_tweets.csv", "rb") as f:
# reader = csv.reader(f, delimiter="\t")
# master_row = [""]
# for row in reader:
# master_row = [master_row[col] + row[col] for col in range(0,len(master_row))]
# print master_row
#Coleta automatica dos tweets concatenados em arquivo .csv e utilizacao do extrator de meta-atributos
#with open("[CM30] realwbonner_tweets.csv", "rb") as f:
# reader = csv.reader(f, delimiter="\t")
# for i, line in enumerate(reader):
# print 'tweet [{}] = {}'.format(i, line)
# concatenados = MetaAttributes('{}'.format(line))
# sys.stdout = open("logconcatenadosm30.txt", "a")
# print concatenados.all_meta_attributes
'''
-----------------------------------------------------------------------------------------------------------------------
(3) TESTE DO EXTRATOR DE META-ATRIBUTOS (TODOS OS META-ATRIBUTOS) E NORMALIZACAO DO VETOR NUMPY RESULTANTE
-----------------------------------------------------------------------------------------------------------------------
'''
#m1 = MetaAttributes('[Devido ao sucesso de 10 Mandamentos, Record estica o numero de pragas pra 15! @sensacionalista]')
#print m1.all_meta_attributes
# Normalizacao do vetor numpy resultante
#oldmin = min(m1.all_meta_attributes)
#oldmax = max(m1.all_meta_attributes)
#oldrange = oldmax - oldmin
#newmin = 0.
#newmax = 1.
#newrange = newmax - newmin
#if oldrange == 0:
#if oldmin < newmin:
#newval = newmin
#elif oldmin > newmax:
#newval = newmax
#else:
#newval = oldmin
#normalm1 = [newval for v in m1.all_meta_attributes]
#else:
#scale = newrange / oldrange
#normalm1 = [(v - oldmin) * scale + newmin for v in m1.all_meta_attributes]
#print normalm1
'''
-----------------------------------------------------------------------------------------------------------------------
(4) TESTE DO EXTRATOR DE META-ATRIBUTOS (UM A UM)
-----------------------------------------------------------------------------------------------------------------------
'''
#m = MetaAttributes('Obrigada aos chantagistas salafrarios chantagiados de merda adorei!')
#print m.C1
#print m.C2
#print m.C3
#print m.C4
#print m.C5
#print m.C6
#print m.C7
#print m.C8
#print m.C9
#print m.C10
#print m.C11
#print m.C12
#print m.C13
#print m.C14
#print m.C15
#print m.C16
#print m.W1
#print m.W2
#print m.W3
#print m.W4
#print m.W5
#print m.W6
#print m.W7
#print m.W8
#print m.W9
#print m.W10
#print m.W11
#print m.W12
#print m.W13_N
#print m.TS1
#print m.TS2
#print m.TS3
#print m.TS4
#print m.TS5
#print m.TS6
#print m.TS7
#print m.TS8
#print m.TS9
#print m.TS10
#print m.TM1
#print m.TM2
#print m.TM3
#print m.TM4
#print m.TM5
#print m.TM6
#print m.PC1
#print m.PC2
#print m.PC3
#print m.PC4
#print m.PC5
'''
-----------------------------------------------------------------------------------------------------------------------
(5) TESTE DO PROCESSADOR TEXTUAL
-----------------------------------------------------------------------------------------------------------------------
'''
#print ("oi")
docsTokenized = tp.remove_accents(['GOVERNO de SP vai pagar 25 mil a quem denunciou suspeito de matar ambulante no Metro. Secretaria de Seguranca Publica fixou valor nesta quarta (18) no Diario Oficial.'])
print(docsTokenized)