#K48732. Word Frequency Counter
Word Frequency Counter
Word Frequency Counter
You are given a paragraph of text. Your task is to count the frequency of each unique word present in the paragraph. The count should be case-insensitive and all punctuation must be removed.
Note: The output should be a JSON object where the keys are the words (in lowercase) and the values are their frequency counts. When printing the output, the keys must be sorted in lexicographical order.
For instance, if the input is:
Hello, hello! How are you? I hope you are doing well.
Then the output should be:
{"are": 2, "doing": 1, "hello": 2, "hope": 1, "how": 1, "i": 1, "well": 1, "you": 2}
inputFormat
The input consists of a single line which is a paragraph of text. The text may contain letters, numbers, punctuation, and whitespace characters.
You should read the entire input from stdin
.
outputFormat
Output a JSON object (as a string) representing the word frequency counter. The keys in the JSON object should be sorted in lexicographical order. Print the output to stdout
.
Hello, hello! How are you? I hope you are doing well.
{"are": 2, "doing": 1, "hello": 2, "hope": 1, "how": 1, "i": 1, "well": 1, "you": 2}