Commit a319c0c8 authored by Sparsh Jauhari's avatar Sparsh Jauhari 💬
Browse files

Removed comments

parent 6b13c8eb
......@@ -79,19 +79,12 @@ def count_vectorize_transform(vectorizer_binary,x_list):
return X
def elmo_transform(x_list):
elmo = hub.load("https://tfhub.dev/google/elmo/3")
embeddings_list = []
vector = np.vectorize(np.float)
embeddings_list = []
for sent in x_list:
sent = preProcessAndTokenize(sent)
sent = ' '.join(sent)
#print('\nSENTENCE Length:', len(sent))
#print('\nSENTENCE:', sent)
#print((tf.constant(sent))
embeddings = elmo.signatures["default"](tf.constant([sent]))
#embeddings_list.append(vector(tf.reshape(embeddings['word_emb'], [-1]).numpy()))
embeddings_list.append(np.mean(embeddings['word_emb'],1).flatten())
#elmo(sent, signature="default", as_dict=True)["elmo"]
#yup =tf.keras.backend.eval(embeddings)['word_emb']
sent = ' '.join(sent)
embeddings = elmo.signatures["default"](tf.constant([sent]))
embeddings_list.append(np.mean(embeddings['word_emb'],1).flatten())
return (embeddings_list)
class MeanEmbeddingVectorizer(object):
......@@ -144,26 +137,6 @@ def selftrained_word2vec_fit_transform(x_list):
return model , X
data = get_data_from_mongo('trial')
data = pd.DataFrame(data)
s= data['bio'][0]
s2 = data['bio'][1]
y=[s,s2]
print(y)
#elmo_transform(data['bio'])
#print(elmo_transform(y))
#print(embeddings['word_emb'])
#print(embeddings)
X_train = elmo_transform(y)
classifier = SVC(C=1, kernel = 'linear', gamma = 'auto', class_weight=None)
#X_train = tf.reshape(X_train, [1])
print("first instance of X_train\n", type(X_train[0]),X_train[0].shape, X_train[0].ndim, X_train[0].size)
print(X_train)
classifier.fit(X_train, ['1','0'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment