user.py
def save(self):
		"""
		Save the user in the corresponding file
		:return:
		"""
		users_data = {}  # user_id => line

		self.create_files()
		f = open(User.user_fname if type(self.id) is int else User.author_fname, "r")
		contents = f.readlines()

		for j in range(1, len(contents)):
			items = contents[j].split('\t')
			id = int(items[0]) if type(self.id) is int else items[0]
			users_data[id] = j
		f.close()

		to_insert = str(self.id) + '\t' + str(self.nb_click) + '\t' + str(
			list(self.vec)) + '\t' + self.localisation + '\t' + self.gender + '\t' + self.emotion + '\t' + str(
			list(self.topic_vector)) + (('\t' + str(self.centrality)) if type(self.id) is str else '') + '\n'

		# if the id is not in the file
		if self.id not in users_data:
			contents.append(to_insert)
		else:
			contents[users_data[self.id]] = to_insert

		f = open(User.user_fname if type(self.id) is int else User.author_fname, "w")
		for l in contents:
			f.write(l)
		f.close()

		Save the user in the corresponding file
		:return:
		
Save the user in the corresponding file
Save the user in the corresponding file
def save(self):
		users_data = {}  
		self.create_files()
		f = open(User.user_fname if type(self.id) is int else User.author_fname, "r")
		contents = f.readlines()
		for j in range(1, len(contents)):
			items = contents[j].split('\t')
			id = int(items[0]) if type(self.id) is int else items[0]
			users_data[id] = j
		f.close()
		to_insert = str(self.id) + '\t' + str(self.nb_click) + '\t' + str(
			list(self.vec)) + '\t' + self.localisation + '\t' + self.gender + '\t' + self.emotion + '\t' + str(
			list(self.topic_vector)) + (('\t' + str(self.centrality)) if type(self.id) is str else '') + '\n'
		if self.id not in users_data:
			contents.append(to_insert)
		else:
			contents[users_data[self.id]] = to_insert
		f = open(User.user_fname if type(self.id) is int else User.author_fname, "w")
		for l in contents:
			f.write(l)
		f.close()
def save ( self ) : users_data = { } self . create_files ( ) f = open ( User . user_fname if type ( self . id ) is int else User . author_fname , "r" ) contents = f . readlines ( ) for j in range ( 1 , len ( contents ) ) : items = contents [ j ] . split ( '\t' ) id = int ( items [ 0 ] ) if type ( self . id ) is int else items [ 0 ] users_data [ id ] = j f . close ( ) to_insert = str ( self . id ) + '\t' + str ( self . nb_click ) + '\t' + str ( list ( self . vec ) ) + '\t' + self . localisation + '\t' + self . gender + '\t' + self . emotion + '\t' + str ( list ( self . topic_vector ) ) + ( ( '\t' + str ( self . centrality ) ) if type ( self . id ) is str else '' ) + '\n' if self . id not in users_data : contents . append ( to_insert ) else : contents [ users_data [ self . id ] ] = to_insert f = open ( User . user_fname if type ( self . id ) is int else User . author_fname , "w" ) for l in contents : f . write ( l ) f . close ( )
Save the user in the corresponding file
Save the user in the corresponding file
"""
		Save the user in the corresponding file
		:return:
		""" # user_id => line # if the id is not in the file
None
self