@@ -0,0 +1,786 @@
+import sys%0Aimport json%0Aimport time%0Afrom sklearn.cluster import KMeans %0A%0Anum_words = int(sys.argv%5B1%5D)%0Anum_clusters = int(sys.argv%5B2%5D)%0Af = open(%22google-10000-vectors.json%22,%22r%22).read().split(%22%5Cn%22)%0Aword_list = %5B%5D%0Avector_list = %5B%5D%0Afor i in range(0,num_words):%0A%09j = json.loads(f%5Bi%5D)%0A%09word_list.append(j%5B0%5D)%0A%09vector_list.append(j%5B1%5D)%0A%0A%0Aold_time = time.time()%0Akmeans_clust = KMeans(n_clusters = num_clusters)%0Aidx = kmeans_clust.fit_predict(vector_list)%0Anew_time = time.time()%0Aprint(%22Time taken for clustering%22, new_time - old_time)%0A%0Ak=%5B%5B%5D for x in range(num_clusters)%5D%0A%0Aword_centroid_map = dict(zip(word_list,idx))%0Afor word in word_centroid_map.keys():%0A%09k%5Bword_centroid_map%5Bword%5D%5D.append(word)%0A%0Aopen(%22Kmeans-%22+str(num_words)+%22words-%22+str(num_clusters)+%22clusters.json%22,%22w%22).write(json.dumps(k))%0A

Set Building Implemented * word2vec vectors generated from vocabulary file * KMeans clustering employed for grouping semantically similar vectors * storing as seperate files with group of similar sets