Kami Export - ap-computer-science-a-consumer-review-lab-student-guide (3) (1) - Name \u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003\u2003 Date

Kami Export - ap-computer-science-a-consumer-review-lab-student-guide (3) (1)

This preview shows page 1 - 4 out of 12 pages.

Name: Date: ACTIVITY 1 Introduction (Reviews and Sentiment Value) The persuasive power of words can be seen in a variety of places such as entertainment, news, social media, and even reviews and comments. This activity focuses on the sentiment value of individual words, and you will start by reading a few online reviews of your choice. 1. In this activity you’ll be calling the sentimentValmethod. Find this method in the Reviewclass and answer the following questions: a. Record the method signature in the space below. b. Does this method require a parameter? If so, what type of parameter is required? What happens if you pass a different type of parameter instead? (Try it!)c. Does the method return a value? If so, what is the return type? 2. Write code that tests the sentimentValmethod by calling it with several differentStringparameters and printing out the return value. Any words not in the list will have a return value of zero. Make sure to keep calling the method until you have at least three strings that have a return value other than zero. Record the method calls, including provided strings and return values in the chart below: Examples: Method Call Return Value sentimentVal(“happily”); 2.32 sentimentVal(“terrible”); -3.38 sentimentVal(“cold”); -0.04 AP Computer Science A Student Lab Handout 1
Consumer Review Lab: Introduction (Reviews and Sentiment Value) Method Call Return Value Open up the cleanSentiment.csv file and look up a few of the words that were used in the method call to verify the results. Check Your Understanding 3. Determine whether or not each statement would compile. Briefly justify your answers. a. double num = sentimentVal(“warm”); b. String word = sentimentVal(0.5); c. double x = sentimentVal(“good”, “bad”); AP Computer Science A Student Lab Handout 2
Name: Date: ACTIVITY 2 Sentiment Value and Star Ratings Now that you have read several reviews and started exploring the sentimentVal method, you will use this method to determine the overall sentiment of an entire review. § Pick a review of your choice. Copy and paste the content of the review into a new text file that you create using a text editor, making sure to save the file with a .txt extension. § If time permits, do this with multiple reviews. For testing purposes, you may also want to create a SimpleReview.txt file like the following: This was a terrible restaurant! The pizza crust was too chewy, and I disliked the pasta. I would definitely not come back. Tip Strings are objects and have methods that can access information about them and create new strings. The course framework describes those methods which are part of the course, such as length , indexOf , and substring .

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture