#C140. Keyword Casing Correction
Keyword Casing Correction
Keyword Casing Correction
Given a list of keywords with their correct casing and a document (a series of text lines), your task is to replace all case-insensitive occurrences of each keyword in the document with its correct casing. The replacement should occur only when the occurrence is a whole word.
A whole word is defined by the boundaries (denoted by the regex token \b
) such that the keyword is preceded and followed by a non-word character (or the edge of the line). In LaTeX, a whole word occurrence can be represented as: $$ \text{\b}(\text{keyword})\text{\b} $$.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer M, the number of keywords.
- The next M lines each contain a keyword in its correct casing.
- The following line contains an integer N, the number of lines in the document.
- The next N lines each contain a line of text from the document.
outputFormat
Output the document with corrected casing on stdout. Each of the N lines should be printed in the same order as the input.
## sample3
python
Java
C++
4
I love python and PYTHON.
JAVA is widely used.
Writing code in c++ and java.
python Java C++ are popular languages.
I love python and python.
Java is widely used.
Writing code in C++ and Java.
python Java C++ are popular languages.
</p>