本文整理汇总了C++中Movie::GetID方法的典型用法代码示例。如果您正苦于以下问题:C++ Movie::GetID方法的具体用法?C++ Movie::GetID怎么用?C++ Movie::GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Movie
的用法示例。
在下文中一共展示了Movie::GetID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strcpy
Movie::Movie(const Movie &cpy):name(cpy.GetName()) {
movieID = cpy.GetID();
language = new char[strlen(cpy.GetLanguage())+1];
strcpy(language, cpy.GetLanguage());
for (register int i = 0; i < 8; i++) {
const int *temp = cpy.GetRelDate();
relDate[i] = temp[i];
}
category = cpy.GetCategory();
inCinemas = cpy.GetCinemaList();
}
示例2: main
int main(int argc, char ** argv)
{
if (argc != 3)
{
cerr << "Usage: " << argv[0] << " personIndex recNum\n";
return 1;
}
ifstream oFileIn;
string strLine;
///load movie info
oFileIn.open(g_pMovieData, ios::in);
Movie oMovie;
while (getline(oFileIn, strLine))
{
Parser::ParseMovie(strLine, oMovie);
g_mapMovieInfo[oMovie.GetID()] = oMovie;
}
oFileIn.clear();
oFileIn.close();
///load user info
oFileIn.open(g_pUserData, ios::in);
User oUser;
while (getline(oFileIn, strLine))
{
Parser::ParseUser(strLine, oUser);
g_mapUserInfo[oUser.GetID()] = oUser;
}
oFileIn.clear();
oFileIn.close();
///load rating
oFileIn.open(g_pRatingData, ios::in);
Rating oRating;
while (getline(oFileIn, strLine))
{
Parser::ParseRating(strLine, oRating);
g_mapRatingInfo[oRating.GetUserID()][oRating.GetMovieID()] = oRating;
}
oFileIn.close();
size_t unMaxUserNum = g_mapUserInfo.rbegin()->first;
size_t unMaxMovieNum = g_mapMovieInfo.rbegin()->first;
///allocate memory
g_szRatings = new double*[unMaxUserNum];
for (size_t unIdx = 0; unIdx < unMaxUserNum; ++ unIdx)
{
g_szRatings[unIdx] = new double[unMaxMovieNum];
::memset(g_szRatings[unIdx], 0, sizeof(double)*unMaxMovieNum);
}
///get critics
map<int, User>::iterator oItUser = g_mapUserInfo.begin();
while (oItUser != g_mapUserInfo.end())
{
map<int, Rating>::iterator oItRating = g_mapRatingInfo[oItUser->first].begin();
while (oItRating != g_mapRatingInfo[oItUser->first].end())
{
g_szRatings[oItUser->first - 1][oItRating->first - 1] = oItRating->second.GetRate();
++ oItRating;
}
++ oItUser;
}
int nPersonIndex = ::atoi(argv[1]) - 1;
int nRecNum = ::atoi(argv[2]);
int * pRecItems = new int[nRecNum];
double * pRecScores = new double[nRecNum];
///Euclidean
GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum,
unMaxMovieNum, nPersonIndex, GetEuclideanScore, nRecNum, pRecItems, pRecScores);
cout << "---------------------Euclidean Recommendation: \n";
for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
{
cout << nIdx << "\t" << pRecScores[nIdx] << "\t"
<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
}
///Pearson
GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum,
unMaxMovieNum, nPersonIndex, GetPearsonScore, nRecNum, pRecItems, pRecScores);
cout << "\n---------------------Pearson Recommendation: \n";
for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
{
cout << nIdx << "\t" << pRecScores[nIdx] << "\t"
<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
}
///Tanimoto
GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum,
unMaxMovieNum, nPersonIndex, GetTanimotoScore, nRecNum, pRecItems, pRecScores);
cout << "\n---------------------Tanimoto Recommendation: \n";
for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
{
cout << nIdx << "\t" << pRecScores[nIdx] << "\t"
<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
}
//.........这里部分代码省略.........