#C13869. Word Frequency Counter
Word Frequency Counter
Word Frequency Counter
You are given a sentence which may contain letters, digits, punctuation and whitespace. Your task is to count how many times each distinct word appears in the sentence.
When counting words:
- All letters are considered case-insensitively (i.e. 'Hello' and 'hello' are the same word).
- Punctuation and non-alphanumeric characters should be ignored.
After counting, print each word along with its frequency, with each word-frequency pair on a new line. The words must be output in alphabetical order.
Note: If the input is empty or contains no valid words, no output should be produced.
inputFormat
The input is read from standard input (stdin) and consists of a single string (which may include spaces and punctuation) representing the sentence.
outputFormat
For each distinct word, output a line containing the word followed by a single space and then its frequency. The words must appear in alphabetical order. If there are no words, output nothing.
## sampleHello, world! Hello again, world.
again 1
hello 2
world 2
</p>