#C4797. Review Classifier
Review Classifier
Review Classifier
You are given two sets of keywords: positive keywords and negative keywords, along with a list of product reviews. For each review, your task is to classify it as positive
if the review contains at least one positive keyword and does not contain any negative keywords; otherwise, the review should be classified as negative
.
The classification is done on a word basis. A review is only considered positive if it contains at least one of the positive keywords and none of the negative keywords. If a review contains both positive and negative keywords, it should be classified as negative.
Note: Words are separated by spaces. Ensure that you consider exact word matching.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains a space-separated string of positive keywords.
- The second line contains a space-separated string of negative keywords.
- The third line contains an integer N indicating the number of reviews.
- The following N lines each contain a review.
outputFormat
For each review, output a single line to standard output (stdout) containing either positive
or negative
based on the classification criteria.
good excellent amazing
bad terrible
3
this product is good and amazing
the quality is terrible
excellent choice for everyone
positive
negative
positive
</p>