SEARCH OUTPUT:<SPACE><movie id>|<movie title>|<number of ratings>|average rating><NEWLINE>
This is a subset of the kind of data that IMDB or Netflix prints out when you search for a movie on their web sites.
Here is the snippet of code for this specific part:
//STEP 3
void read_uitem() { //Reading file u.item
ifstream read_stream;
string input_line;
read_stream.open("u.item");
if(read_stream.is_open() == false) {
cout << "Error!";
exit(-1);
}
string movieIDString;
int movieID = 0;
string title;
string line;
while(read_stream) { //Running loop to find the MovieID
getline(read_stream, line);
int start = 0;
int end = (int)line.find("|");
movieIDString = line.substr(start, end);
start = end;
start++;
end = (int)line.find("|", start);
title = line.substr(start, end - start);
movieID = atoi(movieIDString.c_str());
movietitles[movieID] = title;
}
}
void getInput() {
while(1) { //IS IT JUST A 1
cout << ">>>"; //Prompt for SEARCH OUTPUT:
int line;
cin >> line;
cout << "SEARCH OUTPUT: " << line << endl;
}
}
void read_tabular_file() { //Is this correct?
ifstream read_stream;
string inputline;
cout << "Reading data" << endl;
read_stream.open("ratings.txt");
if (read_stream.is_open() == false) {
cout <<"Error in opening file!" << endl;
exit(-1);
}
while(true) {
int movieID;
string title;
int rating;
int average_rating;
bool readstatus = (read_stream >> " " >> movieID >> "|" >> title >> "|" >> rating >> "|" >> average_rating >> "\n");
if (readstatus == false) break;
}
read_stream.close();
}

New Topic/Question
Reply



MultiQuote






|