chap0lin commited on
Commit
5d29d9a
1 Parent(s): ae271fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -33
app.py CHANGED
@@ -110,39 +110,43 @@ def classify(df, new_column = True):
110
  formatted_sentences = []
111
  for sentence in sentencesMCTIList_xp8:
112
  formatted_sentences.append(json.loads(sentence.replace("'",'"')))
113
- del sentencesMCTIList_xp8
114
-
115
- print("Transformado em W2V")
116
- words = list(reloaded_w2v_model.wv.vocab)
117
- item_shape = np.shape(reloaded_w2v_model.wv[words[0]])
118
- # print(formatted_sentences)
119
-
120
- MCTIinput_vector = []
121
- for sentence in formatted_sentences:
122
- aux_vector = []
123
- for word in sentence:
124
- if word in reloaded_w2v_model.wv.vocab:
125
- aux_vector.append(reloaded_w2v_model.wv[word])
126
- else:
127
- aux_vector.append(np.zeros(item_shape))
128
- MCTIinput_vector.append(aux_vector)
129
- del formatted_sentences
130
- print("Convertido W2V")
131
- MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
132
- del MCTIinput_vector
133
- print("Sentenças com Padding")
134
- print(len(MCTIinput_padded))
135
- print(len(MCTIinput_padded[0]))
136
- predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
137
- del MCTIinput_padded
138
- print(predictions)
139
-
140
- cleaned_up_predictions = []
141
- for prediction in predictions:
142
- cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
143
- del predictions
144
-
145
- df['classification'] = cleaned_up_predictions
 
 
 
 
146
  return df
147
 
148
  def gen_output(data):
 
110
  formatted_sentences = []
111
  for sentence in sentencesMCTIList_xp8:
112
  formatted_sentences.append(json.loads(sentence.replace("'",'"')))
113
+ # del sentencesMCTIList_xp8
114
+
115
+ print(sentencesMCTIList_xp8[0])
116
+ print("##########################")
117
+ print(formatted_sentences[0])
118
+
119
+ # print("Transformado em W2V")
120
+ # words = list(reloaded_w2v_model.wv.vocab)
121
+ # item_shape = np.shape(reloaded_w2v_model.wv[words[0]])
122
+ # # print(formatted_sentences)
123
+
124
+ # MCTIinput_vector = []
125
+ # for sentence in formatted_sentences:
126
+ # aux_vector = []
127
+ # for word in sentence:
128
+ # if word in reloaded_w2v_model.wv.vocab:
129
+ # aux_vector.append(reloaded_w2v_model.wv[word])
130
+ # else:
131
+ # aux_vector.append(np.zeros(item_shape))
132
+ # MCTIinput_vector.append(aux_vector)
133
+ # del formatted_sentences
134
+ # print("Convertido W2V")
135
+ # MCTIinput_padded = pad_sequences(MCTIinput_vector, maxlen=2726, padding='pre')
136
+ # del MCTIinput_vector
137
+ # print("Sentenças com Padding")
138
+ # print(len(MCTIinput_padded))
139
+ # print(len(MCTIinput_padded[0]))
140
+ # predictions = reconstructed_model_CNN.predict(MCTIinput_padded)
141
+ # del MCTIinput_padded
142
+ # print(predictions)
143
+
144
+ # cleaned_up_predictions = []
145
+ # for prediction in predictions:
146
+ # cleaned_up_predictions.append(1 if prediction >= 0.5 else 0);
147
+ # del predictions
148
+
149
+ # df['classification'] = cleaned_up_predictions
150
  return df
151
 
152
  def gen_output(data):