#C166. Keyword Frequency Counter
Keyword Frequency Counter
Keyword Frequency Counter
In this problem, you are given a text string and a list of keywords. Your task is to count the frequency of each keyword present in the text. The comparison must be case-insensitive and you are required to ignore the punctuation characters . , ! ? when comparing words. Finally, you must output the frequency of each keyword sorted in alphabetical order.
For example, if the text is "Python is great. Python is dynamic. Everyone loves Python!" and the keywords are ["python", "dynamic", "java"], the output should be:
Note that the counts are obtained only after removing specific punctuation (i.e. . , ! ?) from the words, and comparing them in lowercase.
inputFormat
The input is given from standard input (stdin) and follows this format:
- The first line contains a text string.
- The second line contains an integer n representing the number of keywords.
- The next n lines each contain a keyword.
For example: Python is great. Python is dynamic. Everyone loves Python! 3 python dynamic java
outputFormat
Output the frequency count for each keyword sorted in alphabetical order. Each line of the output should be in the format "keyword: count".
For the sample input above, the output should be:
dynamic: 1 java: 0 python: 3## sample
Python is great. Python is dynamic. Everyone loves Python!
3
python
dynamic
java
dynamic: 1
java: 0
python: 3
</p>