예제 #1
0
 private static void Insert(SqlDataReader reader,
    Dictionary<String, User> users)
 {
     String user_id = reader["user_id"].ToString();
     user_id = user_id.ToLower();
     if (!reader["review_helpfulness"].Equals(DBNull.Value))
     {
         int rating = (int)reader["review_helpfulness"];
         if (rating != -1)
         {
             if (!users.ContainsKey(user_id))
             {
                 User newUser = new User(user_id);
                 newUser.Update(reader["product_category"].ToString(),
                     rating);
                 users.Add(user_id, newUser);
             }
             else
             {
                 User curUser = users[user_id];
                 curUser.Update(reader["product_category"].ToString(),
                     rating);
             }
         }
     }
 }
예제 #2
0
 private static int userExpComparator(User u1, User u2)
 {
     CredibilityInfo info1 = u1.GetCredibilityInfo("Movies");
     CredibilityInfo info2 = u2.GetCredibilityInfo("Movies");
     if (info1.Expertise < info2.Expertise)
         return 1;
     else if (info1.Expertise > info2.Expertise)
         return -1;
     else
     {
         if (info1.RatingCount > info2.RatingCount)
             return -1;
         else if (info1.RatingCount < info2.RatingCount)
             return 1;
         else
             return 0;
     }
 }
예제 #3
0
 private static int userTrComparator(User u1, User u2)
 {
     CredibilityInfo info1 = u1.GetCredibilityInfo("Movies");
     CredibilityInfo info2 = u2.GetCredibilityInfo("Movies");
     if (info1.Trustworthiness < info2.Trustworthiness)
         return 1;
     else if (info1.Trustworthiness > info2.Trustworthiness)
         return -1;
     else
     {
         if (info1.TrusteeCount > info2.TrusteeCount)
             return -1;
         else if (info1.TrusteeCount < info2.TrusteeCount)
             return 1;
         else
             return 0;
     }
 }
예제 #4
0
 private static void InsertIntoTable(User u, String table, SqlConnection connection)
 {
     foreach(String category in User.CategoryName)
     {
         CredibilityInfo info = u.Credibility[category];
         if(info != null)
         {
             String query = "insert into [" + table + "] ";
             query += "values (" + g_count++ + ", "
                 + "'" + u.Name + "', "
                 + "'" + category + "', "
                 + info.Expertise + ", "
                 + info.RatingCount + ", "
                 + info.Trustworthiness + ", "
                 + info.TrusteeCount + ")"
                 ;
             SqlCommand cmd = new SqlCommand(query, connection);
             cmd.ExecuteNonQuery();
         }
     }
 }