import gptc states = [ "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", ] with open("model.gptc", "rb") as f: model = gptc.deserialize(f) classified_states = [] for state in states: classified_states.append((state, model.get(state),)) classified_states.sort(key=lambda x: x[1]["left"]) longest = max([len(state) for state in states]) print("# State Analysis") print() print("""This is an analysis of which states are mentioned more in right- or left- leaning American news sources. Results do not necessarily correlate with the political views of residents of the states; for example, the predominantly liberal state of Oregon is mentioned more in right-leaning sources than in left-leaning ones.""") print() print("| State | Left | Right |") print("+----------------+-------+-------+") for state, data in classified_states: percent_right = f"{round(data['right']*1000)/10}%" percent_left = f"{round(data['left']*1000)/10}%" state_padding = " "*(longest - len(state)) print(f"| {state}{state_padding} | {percent_left} | {percent_right} |") print("+----------------+-------+-------+") print("| State | Left | Right |")