def category_bag_of_words(restaurants):
    """
    Get bag of words representation of restaurant's categories.

    Parameters:
        restaurants - a list of restaurant dictionary objects

    Returns:
        A bag of words dictionary, key-value pairings are category->category count.
    """
    bag = {}
    for restaurant in restaurants:
        categories = restaurant["categories"]
        for c in categories:
            bag[c] = bag.get(c,0)+1
    return bag