/**
   * @param user
   * @return
   * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector"
   *     variable of the com.post.parser.model.User class. It gives the total number of posts in the
   *     specified day range which has been described in getDayCategory(int DayOfWeek) in this
   *     class.
   */
  public User setCategorizedDayOfMonthToUser(User user) throws ParseException {
    int[] userDayOfMonthVector = user.getClassifiedDayOfMonthVector();
    for (Posts posts : user.getUserPost()) {
      String date = posts.getDate();
      int DayOfMonth = getDayOfMonth(date) - 1;
      userDayOfMonthVector[DayOfMonth] = userDayOfMonthVector[DayOfMonth] + 1;
    }
    user.setClassifiedDayOfMonthVector(userDayOfMonthVector);

    return user;
  }
  /**
   * @param user
   * @return
   * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector"
   *     variable of the com.post.parser.model.User class. It gives the total number of posts in the
   *     specified day range which has been described in getDayCategory(int DayOfWeek) in this
   *     class.
   */
  public User setCategorizedMonthToUser(User user) throws ParseException {
    int[] userMonthVector = user.getClassifiedMonthVector();
    for (Posts posts : user.getUserPost()) {
      String date = posts.getDate();
      int MonthOfYear = getMonthOfYear(date);
      //                System.out.println("Day Of Week " + DayOfWeek);
      userMonthVector[MonthOfYear] = userMonthVector[MonthOfYear] + 1;
    }
    user.setClassifiedMonthVector(userMonthVector);

    return user;
  }
  /**
   * @param user
   * @return
   * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector"
   *     variable of the com.post.parser.model.User class. It gives the total number of posts in the
   *     specified day range which has been described in getDayCategory(int DayOfWeek) in this
   *     class.
   */
  public User setCategorizedDayToUser(User user) throws ParseException {
    int[] userDayVector = user.getClassifiedDayVector();
    for (Posts posts : user.getUserPost()) {
      String date = posts.getDate();
      int DayOfWeek = getDayOfWeek(date) - 1;
      //                System.out.println("Day Of Week " + DayOfWeek);
      userDayVector[DayOfWeek] = userDayVector[DayOfWeek] + 1;
    }
    user.setClassifiedDayVector(userDayVector);

    return user;
  }
 /**
  * @param userList
  * @return
  * @throws java.text.ParseException @Desc This function populates the "classifiedDayVector"
  *     variable of the com.post.parser.model.User class. It gives the total number of posts in the
  *     specified day range which has been described in getDayCategory(int DayOfWeek) in this
  *     class.
  */
 public List<User> setCategorizedDayOfMonthToUser(List<User> userList) throws ParseException {
   for (User user : userList) {
     int[] userDayOfMonthVector = user.getClassifiedDayOfMonthVector();
     for (Posts posts : user.getUserPost()) {
       String date = posts.getDate();
       int DayOfMonth = getDayOfMonth(date) - 1;
       System.out.println("Day Of Week " + DayOfMonth);
       userDayOfMonthVector[DayOfMonth] = userDayOfMonthVector[DayOfMonth] + 1;
     }
     user.setClassifiedDayOfMonthVector(userDayOfMonthVector);
   }
   return userList;
 }
  /**
   * @param user
   * @return user @Desc This function populates the "classifiedTimeVector" variable of the
   *     com.post.parser.model.User class. It gives the total number of posts in the specified time
   *     range which has been described in getTimeCategory(int hours) in this class.
   */
  public User setCategorizedHourOfDayToUser(User user) {
    int[] userTimeVector = user.getClassifiedHourOfDayVector();
    for (Posts posts : user.getUserPost()) {
      Timestamp ts =
          Timestamp.valueOf(
              new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime()));
      int timeCategory = ts.getHours();
      userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1;
    }
    user.setClassifiedHourOfDayVector(userTimeVector);

    return user;
  }
  /**
   * @param user
   * @return user
   * @throws java.text.ParseException @Desc This function populates the "classifiedTimeVector"
   *     variable of the com.post.parser.model.User class. It gives the total number of posts in the
   *     specified time range which has been described in getTimeCategory(int hours) in this class.
   */
  public User setCategorizedTypeOfWeekToUser(User user) throws ParseException {
    int[] userTimeVector = user.getClassifiedTypeOfWeekVector();
    for (Posts posts : user.getUserPost()) {
      String date = posts.getDate();
      int dayOfWeek = getDayOfWeek(date);
      int typeOfWeek = getTypeOfWeek(dayOfWeek);

      userTimeVector[typeOfWeek] = userTimeVector[typeOfWeek] + 1;
    }
    user.setClassifiedTypeOfWeekVector(userTimeVector);

    return user;
  }
 /**
  * @param userList
  * @return
  * @throws java.text.ParseException @Desc This function populates the
  *     "classifiedSixMonthDataVector" variable of the com.post.parser.model.User class. It gives
  *     the total number of posts of only six months
  */
 public List<User> setCategorizedSixMonthDataToUser(List<User> userList) throws ParseException {
   for (User user : userList) {
     int[] userMonthVector = user.getClassifiedSixMonthDataVector();
     for (Posts posts : user.getUserPost()) {
       String date = posts.getDate();
       int MonthOfYear = getMonthOfYear(date);
       if (MonthOfYear <= 5) {
         userMonthVector[MonthOfYear] = userMonthVector[MonthOfYear] + 1;
       }
     }
     user.setClassifiedMonthVector(userMonthVector);
   }
   return userList;
 }
 public List<User> generateUserSecondActivityCluster(List<User> userList) {
   for (User user : userList) {
     List postList = user.getUserPost();
     int requiredPostValue = (int) (0.20 * postList.size());
     int[] secondActivityCluster = user.getSecondActivityVector();
     int[] tempClassifiedTimeVector = user.getClassifiedTimeVector();
     for (int i = 0; i < secondActivityCluster.length; i++) {
       if (tempClassifiedTimeVector[i] > requiredPostValue) {
         secondActivityCluster[i] = 1;
       }
     }
     user.setSecondActivityVector(secondActivityCluster);
   }
   return userList;
 }
 /**
  * if user has posted less than or equal to 8 percent of total message then it will be consider as
  * his sleeping time
  *
  * @param userList
  * @return
  */
 public List<User> generateUserSleepingCluster(List<User> userList) {
   for (User user : userList) {
     int[] sleepingCluster = user.getSleepingClusterVector();
     int[] tempClassifiedTimeVector = user.getClassifiedTimeVector();
     List postList = user.getUserPost();
     int requiredSleepingPostValue = (int) (0.08 * postList.size());
     //            int requiredSleepingPostValue = 5;
     for (int i = 0; i < sleepingCluster.length; i++) {
       if (tempClassifiedTimeVector[i] <= requiredSleepingPostValue) {
         sleepingCluster[i] = 1;
       }
     }
     user.setSleepingClusterVector(sleepingCluster);
   }
   return userList;
 }
Beispiel #10
0
  /**
   * @param user @Desc This function populates the "classifiedTimeVector" variable of the
   *     com.post.parser.model.User class. It gives the total number of posts in the specified time
   *     range which has been described in getTimeCategory(int hours) in this class.
   * @return List<User>
   */
  public User setCategorizedTimeToUser(User user) {
    ClusterCommons cc = new ClusterCommons();
    int[] userTimeVector = user.getClassifiedTimeVector();
    for (Posts posts : user.getUserPost()) {
      Timestamp ts =
          Timestamp.valueOf(
              new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime()));
      int timeCategory = cc.getTimeCategory(ts.getHours());
      if (timeCategory < 6) {
        userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1;
      }
    }
    user.setClassifiedTimeVector(userTimeVector);

    return user;
  }
Beispiel #11
0
 /*
  * Generates first activity user cluster by taking the maximum number
  * of posts posted by user
  */
 public List<User> generateUserMostActiveCluster(List<User> userList) {
   for (User user : userList) {
     int[] firstActivityCluster = user.getFirstActivityVector();
     int[] tempClassifiedTimeVector = user.getClassifiedTimeVector();
     int max = 0;
     int maxIndex = 0;
     for (int i = 0; i < tempClassifiedTimeVector.length; i++) {
       if (tempClassifiedTimeVector[i] > max) {
         max = tempClassifiedTimeVector[i];
         maxIndex = i;
       }
     }
     firstActivityCluster[maxIndex] = 1;
     user.setFirstActivityVector(firstActivityCluster);
   }
   return userList;
 }
Beispiel #12
0
 public HashMap<Integer, Set> generateUserCluster(List<User> userList) {
   HashMap<Integer, Set> userCluster;
   userCluster = new HashMap<>();
   Set<Integer> firstClusterList = new TreeSet<>();
   Set<Integer> secondClusterList = new TreeSet<>();
   Set<Integer> thirdClusterList = new TreeSet<>();
   Set<Integer> fourthClusterList = new TreeSet<>();
   Set<Integer> fifthClusterList = new TreeSet<>();
   Set<Integer> sixthClusterList = new TreeSet<>();
   for (User user : userList) {
     // int[] firstActivityCluster = user.getFirstActivityVector();
     int[] tempClassifiedTimeVector = user.getClassifiedTimeVector();
     int max = 0;
     int maxIndex = 0;
     for (int i = 0; i < tempClassifiedTimeVector.length; i++) {
       if (tempClassifiedTimeVector[i] > max) {
         max = tempClassifiedTimeVector[i];
         maxIndex = i;
       }
     }
     if (maxIndex == 0) {
       Integer tempuserID = user.getId();
       firstClusterList.add(tempuserID);
       userCluster.put(1, firstClusterList);
     } else if (maxIndex == 1) {
       int tempuserID = user.getId();
       secondClusterList.add(tempuserID);
       userCluster.put(2, secondClusterList);
     } else if (maxIndex == 2) {
       int tempuserID = user.getId();
       thirdClusterList.add(tempuserID);
       userCluster.put(3, thirdClusterList);
     } else if (maxIndex == 3) {
       int tempuserID = user.getId();
       fourthClusterList.add(tempuserID);
       userCluster.put(4, fourthClusterList);
     } else if (maxIndex == 4) {
       int tempuserID = user.getId();
       fifthClusterList.add(tempuserID);
       userCluster.put(5, fifthClusterList);
     } else if (maxIndex == 5) {
       int tempuserID = user.getId();
       sixthClusterList.add(tempuserID);
       userCluster.put(6, sixthClusterList);
     }
     // firstActivityCluster[maxIndex] = 1;
   }
   return userCluster;
 }