def _interactive(pickle_path):
    if ask_user("Input parsed. Save map to %s" % pickle_path, None):
        import cPickle as pickle
        with open(pickle_path, "wb") as f:
            pickle.save(f, id_map)
        print "Done."
    else:
        for (key, value) in id_map.iteritems():
            print key, ":", value
Ejemplo n.º 2
0
def changeSettings():
	easygui.msgbox("Choose your favorite Media Player. This can be changed later", "Ashwin's Badass Simpsons Player")
	playerpath = easygui.fileopenbox(msg="Choose your favorite Media Player", \
									 title="Ashwin's Badass Random Simpsons Player")
	
	if not playerpath:
		sys.exit(0)

	save(playerpath, "UserSettings.SIMPSONS")
	easygui.msgbox("Your new settings have been changed", "Ashwin's Badass Random Simpsons Player")
Ejemplo n.º 3
0
 def save_session_with(self, fields=[]):
     '''
     Given a list of field names, save all of those to a state file.
     '''
     if not self.statefileP:
         return False
     try:
         with open(self.statefileP, 'wb') as f:
             state = dict((f, self.__dict__[f]) for f in fields)
             state = pickle.save(state, f, pickle.HIGHEST_PROTOCOL)
         return True
     except:
         return False
Ejemplo n.º 4
0
    def save(self, subdir='scratch'):
        if not os.path.exists(MODEL_DIR + subdir):
            os.makedirs(MODEL_DIR + subdir)

        for p, name in zip(self.params, self.names):
            pickle.save(p, open(MODEL_DIR + subdir + name + '.pkl', 'w'))
Ejemplo n.º 5
0
class_name = ['m', 'a', 'c', 'u']

filename = 'LEAM-master/data/word2vec_twitter_27B_200d.txt'
model = gensim.models.KeyedVectors.load_word2vec_format(filename)
vector_size = model.vector_size
embedding_vectors = np.random.uniform(-0.001, 0.001,
                                      (len(wordtoix), vector_size))
glove_vocab = list(model.vocab.keys())
count = 0
mis_count = 0

for word in wordtoix.keys():
    idx = wordtoix.get(word)
    if word in glove_vocab:
        embedding_vectors[idx] = model.wv[word]
        count += 1
    else:
        mis_count += 1
print("num of vocab in glove: {}".format(count))
print("num of vocab not in glove: {}".format(mis_count))

print("load class embedding")
name_list = [k.lower().split(' ') for k in class_name]
id_list = [[wordtoidx[i] for i in l] for l in name_list]
value_list = [[opt.W_emb[i] for i in l] for l in id_list]
value_mean = [np.mean(l) for l in id_list]

cPickle.save(open('./data/tweets_emb.p', 'wb'),
             [embedding_vectors, value_mean])
Ejemplo n.º 6
0
			'Change Settings'   : changeSettings(),
			'Play an Episode'   : play,
			'About'			 : about()
		}
		
		choice = easygui.choicebox(msg="What would you like to do?", \
								   title="Ashwin's Badass Simpsons Player", \
								   choices=name_to_func.keys())
		if not choice:
			sys.exit(0)
			
		if choice == "Play an Episode":
			mustLoadSettings = easygui.buttonbox(msg="Use Previous settings?", \
									 title="Ashwin's Badass Random Simpsons Player", \
									 choices=("Yes", "No"))
		
			if mustLoadSettings == "YES":
				playerPath = load(open('UserSettings.SIMPSONS'))
				save = easygui.ynbox("Save New Settings?", "Ashwin's Badass Simpsons Player")
				if save:
					try:
						save(playerPath, "UserSettings.SIMPSONS")
						easygui.msgbox("New Settings Saved", "Ashwin's Badass Simpsons Player")
					except Exception, e:
						easygui.msgbox("ERROR:\n%s"%e, "Ashwin's Badass Simpsons Player")
			
				rootDir = None
				while not rootDir:
					rootDir = easygui.diropenbox("Where are all the show files located?", "Ashwin's Badass Simpsons Player")
	
				play(rootDir, playerPath)
Ejemplo n.º 7
0
    def save(self, subdir='scratch'):
        if not os.path.exists(MODEL_DIR + subdir):
            os.makedirs(MODEL_DIR + subdir)

        pickle.save([p.get_value() for p in self.params],
                    open(MODEL_DIR + subdir + 'params.pkl', 'w'))