#C13259. Word Count

    ID: 42777 Type: Default 1000ms 256MiB

Word Count

Word Count

Given a sentence, your task is to count the frequency of each word in the sentence while ignoring punctuation and case. The words are defined as contiguous sequences of alphanumeric characters. In other words, all punctuation should be treated as whitespace. The output must be a JSON object representing the frequency dictionary. Moreover, the keys in the output JSON must be sorted in alphabetical order.

For example, if the input is This is a sentence, the expected output is {"a":1,"is":1,"sentence":1,"this":1}.

Note: You should treat words as case insensitive. That is, "Hello" and "hello" are considered the same word. If the input string is empty or contains only spaces, output an empty JSON object: {}.

You may find the following LaTeX formula helpful when considering string processing: $$ \text{Frequency}(w) = \sum_{i=1}^{n} \mathbb{1}_{\{w_i = w\}}, $$ where \(w_i\) denotes the i-th word in the sentence and \(\mathbb{1}\) is the indicator function.

inputFormat

The input is provided via stdin as a single line consisting of a sentence.

outputFormat

The output should be printed to stdout. It must be a JSON object with no extra spaces, representing the frequency dictionary with keys sorted in alphabetical order. For example: {"a":1,"is":1,"sentence":1,"this":1}

## sample
This is a sentence
{"a":1,"is":1,"sentence":1,"this":1}