#C7457. Word Count in Text Block
Word Count in Text Block
Word Count in Text Block
In this problem, you are given a list of words and a block of text. Your task is to count the occurrence of each word from the list in the text. The words are case-insensitive, and punctuation should be ignored. You need to process the text properly using regular expressions, and output the count of each queried word in the order they are given.
Formally, for each word \(w\) in the list, find the number of occurrences of \(w\) in the text. Here, a word is defined by the regex pattern \(\texttt{\\b\\w+\\b}\). This means that every contiguous sequence of alphanumeric characters is treated as a word.
inputFormat
The input is received via standard input in the following format:
- An integer \(N\) representing the number of words to be counted.
- A line containing \(N\) space-separated words.
- An integer \(M\) representing the number of lines in the text block.
- \(M\) lines of text.
outputFormat
Print the counts of each word in the order they were given, separated by a single space, to standard output.
## sample3
hello world example
2
hello! world. this is an example.
is this the example, or another example?
1 1 3