Question: Write a program to determine how many actors there are in the data set in Worked Example 19.2. Note that many actors are in multiple
Write a program to determine how many actors there are in the data set in Worked Example 19.2. Note that many actors are in multiple movies. The challenge in this assignment is that each movie has a list of actors, not a single actor, and there is no ready-made collector to form the union of these lists. However, there is another collect method that has three parameters:
• A function to generate an instance of the target • A function to add an element to a target • A function to merge two targets into one for example, stream.collect(() -> 0, (t,e) -> t +e, (t, u) -> t + u) computes the sum of elements in a Stream
Define methods for generating a set, adding a list of actors into one, and for combining two sets.
Data from worked example 19.2.







WORKED EXAMPLE 19.2 A Movie Database In this worked Example, we analyze a large database of movies and use streams to obtain interesting statistics from the data. To follow along, locate the companion code for Worked Example 19.2. Problem Statement The file movies.txt in the book's companion code has information about 23,000 movies, taken from the database of facts at http://freebase.com. Each movie has a year, title, and lists of directors, producers, and actors. What interesting facts can you find? CINEMAS IM Ivan Cholakov/iStockphoto.
Step by Step Solution
3.50 Rating (157 Votes )
There are 3 Steps involved in it
The problem statement in the provided text asks us to write a program that calculates the number of unique actors across all movies in a dataset where ... View full answer
Get step-by-step solutions from verified subject matter experts
