#K80742. Word Frequency Counter
Word Frequency Counter
Word Frequency Counter
Your task is to write a program that reads a sentence from standard input and counts the frequency of each word, ignoring punctuation and treating words as case-insensitive.
Words are defined as contiguous sequences of alphanumeric characters (letters and digits). All punctuation should be ignored. For example, in the sentence "Hello, world! hello.", the word counts are {"hello": 2, "world": 1}.
The output should be a dictionary (or map), in JSON format, where the keys are the words in lowercase and the values are their corresponding frequencies. The keys in the output should be sorted in lexicographical order.
inputFormat
The input consists of a single line containing a sentence. The sentence may contain letters, digits, spaces, and punctuation.
outputFormat
Output a JSON formatted dictionary representing the count of each word. The dictionary must have its keys sorted in lexicographical order. For example: {"hello": 2, "world": 1}
hello
{"hello":1}