import sys
import json
import matplotlib.pyplot as plt

LABELS = ["Low Reviews", "Medium Reviews", "High Reviews"]

def load_dictionary_from_json(filename):
    """
    This function opens the json file, loads it into a variable and returns the variable.
    """
    # YOUR CODE HERE to make a plot for the woman data for a given word
    pass

def plot_women_words(word_data, word, max_frequency):
    """
    This function takes in the word_data dictionary, the word, and the max_frequency.
    Your job is to use the dictionary and the word to plot the frequencies for this word
    use in low, medium, and high reviews when rating women professors. You do not need to worry
    about the max_frequency parameter. That is used in the provided code.
    """
    # provided code to create a new pyplot figure
    plot1 = plt.figure(1)
    # list of x values to use
    x_vals = [0, 1, 2]

    # YOUR CODE HERE to make a plot for the woman data for a given word
    pass

    # END OF YOUR CODE HERE. The code below is provided for you.
    plt.ylim((0, max_frequency + 500))  # sets the maximum y value for the plot
    plt.xticks(x_vals, LABELS)  # sets the x values to be words for each review category

def plot_man_words(word_data, word, max_frequency):
    """
    This function takes in the word_data dictionary, the word, and the max_frequency.
    Your job is to use the dictionary and the word to plot the frequencies for this word
    use in low, medium, and high reviews when rating male professors. You do not need to worry
    about the max_frequency parameter. That is used in the provided code.
    """
    # provided code to create a new pyplot figure
    plot2 = plt.figure(2)
    # list of x values to use
    x_vals = [0, 1, 2]

    # YOUR CODE HERE to make a plot for the woman data for a given word
    pass

    # END OF YOUR CODE HERE. The code below is provided for you. Uncomment the last line when you are ready.
    plt.ylim((0, max_frequency + 500))  # sets the maximum y value for the plot
    plt.xticks(x_vals, LABELS)  # sets the x values to be words for each review category
    plt.show()


## The code below is provided. Feel free to peruse if you want, but you do not need to change anything below

def main():
    args = sys.argv[1:]
    word_data = load_dictionary_from_json('word_data.json')
    word = args[0]
    gender_data = word_data[word]  # grab the inner dictionary
    max_frequency = max(max(gender_data['W']), max(gender_data['M']))
    plot_women_words(word_data, word, max_frequency)
    plot_man_words(word_data, word, max_frequency)

if __name__ == "__main__":
    main()