#C14759. Word Frequency Analysis

    ID: 44443 Type: Default 1000ms 256MiB

Word Frequency Analysis

Word Frequency Analysis

You are given a list of sentences. Each sentence contains words separated by whitespace. For each word, convert it to lowercase and remove any trailing punctuation (i.e. a period, comma, or exclamation mark). Your task is to compute the frequency of each unique word and print the results in a Python dictionary format (with single quotes for keys). Then, on a new line, print the word with the highest frequency along with its count in the following LaTeX formatted message:

\(\text{The word with the highest frequency is: 'word' with count: count}\)

In the event of a tie, output the first word encountered with the maximum frequency. The input begins with an integer n representing the number of sentences, followed by n sentences.

inputFormat

The first line contains an integer n, the number of sentences. Each of the next n lines contains a sentence.

outputFormat

Output two lines. The first line is a Python-style dictionary (e.g., {'hello': 1, 'world': 1}) showing the word counts. The second line is a message in the format: The word with the highest frequency is: 'word' with count: count## sample

1
Hello world
{'hello': 1, 'world': 1}

The word with the highest frequency is: 'hello' with count: 1

</p>