CR - Create a Positive or Negative Review (Lesson)
Create a Positive or Negative Review
Introduction
Fake reviews can be slanted positively or negatively. To create a positive review the program only needs to substitute positive adjectives for neutral or negative adjectives. To create a negative review the program would substitute only negative adjectives for neutral or positive adjectives. In this activity you’ll modify the fakeReview method written previously. The method will be redesigned so that it will make reviews stronger; that is, either more negative or more positive.
Stronger Reviews
In this activity, you will modify the fakeReview method that you wrote in the previous activity. The method (in the Review class) will be redesigned so that it will make reviews stronger; that is, either more negative or more positive.
First, consider the following:
- Determine the possible reason to autogenerate a negative review.
- Determine one possible reason to autogenerate a positive review.
- What does the fakeReview method need to do to create a strong review?
After you have brainstormed what the fakeReview method needs, update the fakeReview method to create a stronger review.
Utilize the following pseudocode to help you update the method:
- Have the method loop over the words in the review. Each time the method finds an adjective, pass the adjective to the sentimentVal method in Review to determine its sentiment value, v.
- When trying to create a more positive review, call the randomPositiveAdj method to obtain a new adjective. Find the sentiment value of the new adjective and compare its sentiment value to the original adjective until an adjective with a greater sentiment value is chosen (check this by calling sentimentVal and passing whatever adjective gets returned).
- When trying to create a more negative review, call the randomNegativeAdj method to obtain a new adjective. Find the sentiment value of the new adjective and compare its sentiment value to the original adjective until an adjective with a lesser (more negative) sentiment value is chosen (check this by calling sentimentVal and passing whatever adjective gets returned).
- Replace the original adjective with the new adjective in the output string.
Once the entire review has been processed, return the new review string.
This lab content is from the CollegeBoard Links to an external site..
Lab Check
Record the answers to the following questions on a sheet of paper. You will need the answers to complete the Lab Check Quiz.
- What is the result of the following statement?
- oneWord = oneWord.substring(1);
- Why was it necessary to remove the * character used to annotate the adjective before getting its sentiment value?
- You wrote a method that created a more positive or more negative review. How could this method be used or modified to create a super positive review (one that is extremely favorable)?
IMAGES CREATED BY GAVS