def count(rdd, field_name):
    """Perform a word count on the specified field of the input rdd by tokenizing the text.
    Return an rdd of dicts with "word" and "count" fields.
    """
    # Split the text in the records into lowercase words
    words = rdd.flatMap(lambda r: r[field_name].lower().split()) 

    # Generate pairs
    ones = words.map(lambda word: (word, 1))

    # Sum up the counts for each word
    word_count_tuples = ones.reduceByKey(lambda count, amount: count + amount)

    # Convert to dicts
    word_count_dicts = word_count_tuples.map(lambda pair: {"count": pair[1], "word": pair[0]})

    return word_count_dicts