def read_topic(self, input_file="topic_list/topic_0.txt", split_sign=":"): """ Read in a specific topic from a file named <input_file> :param input_file: the name of the file that stores the topic :return: a topic containing a list of word distribution tuples """ # read in all ines of input except the last line which is an empty new line input_file = open(input_file, 'r') word_dist = input_file.readlines() # Create the topic object # The topic object contains a list of word distribution tuples topic = Topic() for dist in word_dist: dict = dist.strip().split(split_sign) topic.add((dict[0], float(dict[1]))) return topic