def get_img_to_cap_dict(filename):
	"""
	Opens the file storing image to caption mappings.
	Creates a dictionary and adds the mappings as 
	key-value pairs to it.
	Args:
		filename: the name of the file storing image to caption mappings
	Returns:
		img_to_cap_dict: the dictionary storing image to caption mappings
	"""

	file = open(filename, 'r')
	text = file.read()
	file.close()

	img_to_cap_dict = dict()

	for line in text.split('\n'):

		# Split each line by whitespace to get the image name and the caption.
		line_tokens = line.split()

		image_name, caption = line_tokens[0], line_tokens[1:]

		# Produce a string of the caption tokens.
		caption = ' '.join(caption)

		# If the image name is not in the dictionary yet, 
		# create a list to add captions of this image.
		if image_name not in img_to_cap_dict:
			img_to_cap_dict[image_name] = []

		img_to_cap_dict[image_name].append(caption)

	return img_to_cap_dict