


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



[Programming Assignment 4; Due April 8 in class.]
Your program should repeatedly prompt for the names of a set of movie stars. For each such set, it should list out all movies in which they have co-starred. Each set of stars is terminated by a blank line. For example, if the input list is as follows:
Guinness, Alec Sellers, Peter Connor, Kenneth (I)
Then the output should be as shown below:
Submit the output obtained when your program is run on the input file called Query.txt available from your course web page. Note that the file contains several queries. Each query consists of a set of stars. Each set of stars is separated by a blank line. The file is terminated with two blank lines. As usual, also submit the source code for your program and the output of Javadoc. Your floppy diskette should contain all the requisite .java, .class, .html, .dat, .out files that are relevant for the grader to check the program. Do not include the large database of actors and actresses on the zip. Make sure that the hard copy you submit is the same as the copy on the floppy, and is compilable from the floppy. Also include a statement swearing that the submitted work is your own.
There are two data files; both have identical formats. These files are: actors file and actresses file. These files are both compressed in .gz format, and were obtained from the Internet Movie Database. Combined, they are 65.8 Mbytes (compressed!) and were last updated Mar 26, 2004. These files are available in the computer lab in the folder \manatee\giri. YOU MAY NOT COPY THEM INTO ANY OF THE LOCAL FIU MACHINES BECAUSE YOU WILL EXCEED YOUR DISK QUOTA. These datafiles contain approximately 800,000 actors/actresses in a total of less than 250,000 movies, with about 3 million roles. These files also list TV roles, but you must not include TV roles in your analysis. Before you run on the large data sets, use the small (uncompressed) file sample.list to debug the basic algorithms. In this data file, there are six actors, named Ana, A; Berman, Bill; Casper,
Cup; Dill, Diana; Engel, Elaine and Fogel, Frank, who have been in movies such as X, Y, and Z. Here are some useful observations about the data files. You can read the input file line by line by wrapping a FileInputStream inside a BufferedInputStream inside a GZIPInputStream inside an InputStreamReader inside a BufferedReader. You may not uncompress the file outside of your program.
In order to compute your answers, you will need to store the data that you read. The main data structures are (1) a Map in which each key is the name of an Actor and each value is the object for that Actor that contains the corresponding list of movies that the actor has starred in, and (2) a second Map, in which key is a movie and each value is the list of Actors in the movie (i.e., the cast). A movie is represented simply as a String that includes the year in which it was made, but an Actor object includes the name of the actor, and the list of movies in which the actor has starred. The resulting class should look like this:
public class ActorsDB { private static final class Actor { String name;
// list of movies for this actor/actress ArrayList aList = new ArrayList();
ensure that the capacity in the ArrayList is not more than is needed, and you should do so, to avoid wasting space (since there are 700,000 such array lists). When you construct the HashMaps, you can issue a parameter (the load factor). The higher the load factor, the less space you use (at the expense of a small increase in time). You should play around with that too; the default is 0.75. You must be very careful to avoid doing any more work in the inner loops than you need to, including creating excessive objects.
Extensions for the bored Here are some suggestions: