Beispiel #1
0
  private List<Track> getUnderratedPlaylist(List<Track> tempTrackList) {
    Log.d(TAG, "getUnderratedPlaylist()");
    List<Track> tempList = new ArrayList<Track>();

    /**
     * referring to how many times does a song need to be played/selected before it is not a rookie
     * TODO XZ: in future, this should be a relative number such as top played song is at 100
     * completeCount hence an underrated song would be, say maxCount * 0.4?
     */
    int rookieThreshold = 10;

    if (!tempTrackList.isEmpty()) {
      Collections.shuffle(tempTrackList);

      for (Track t : tempTrackList) {

        int completedCount = t.getCompletedCount();
        int skippedCount = t.getSkippedCount();
        int selectedCount = t.getSelectedCount();
        int likedCount = t.getLikedCount();
        int dislikedCount = t.getDislikedCount();

        if (completedCount + selectedCount < rookieThreshold) {
          if (selectedCount > 2) {
            if (skippedCount <= completedCount) {
              tempList.add(t);
            }
          } else {
            if (completedCount > 2) {
              tempList.add(t);
            } else {
              if (likedCount > dislikedCount) {
                tempList.add(t);
              }
            }
          }
        }

        if (tempList.size() == 10) {
          break;
        }
      }
    }

    Log.d(TAG, "tempList.size():" + tempList.size());

    return tempList;
  }
Beispiel #2
0
  private List<Track> getGeneralPlaylist(List<Track> tempTrackList) {
    List<Track> tempList = new ArrayList<Track>();

    if (tempTrackList != null) {
      Collections.sort(
          tempTrackList,
          new Comparator<Track>() {
            @Override
            public int compare(Track left, Track right) {
              return (left.getCompletedCount() + left.getSkippedCount())
                  - (right.getCompletedCount() + right.getSkippedCount());
            }
          });
      Iterator<Track> iter = tempTrackList.iterator();

      while (iter.hasNext()) {
        Track newTrack = iter.next();
        if (newTrack.getSkippedCount() + newTrack.getCompletedCount() > 3) {
          break;
        }

        if (Math.random() > 0.2) {
          tempList.add(newTrack);
          iter.remove();

          if (tempTrackList.size() > 3) {
            break;
          }
        }
      }

      Collections.shuffle(tempTrackList);

      for (Track t : tempTrackList) {
        // Log.d(TAG, "t.getTitle(): " + t.getTitle());

        int completedCount = t.getCompletedCount();
        int skippedCount = t.getSkippedCount();
        // res.where().equalTo("type", TrackStats.SONG_SELECTED) //TODO not implemented yet
        int likedCount = t.getLikedCount();
        int dislikedCount = t.getDislikedCount();

        /**
         * TODO need to make the ratio more representative of the respective counts i.e. if i
         * completed the song once, it should only give like 0.6 but if i completed the song 100
         * times, it should give like 0.9?
         */
        int comMinusSkip = completedCount - skippedCount;
        double cmsRatio = 0;
        if (comMinusSkip > 0) {
          cmsRatio = 0.9;
        } else {
          if (comMinusSkip == 0) {
            cmsRatio = 0.5;
          } else {
            cmsRatio = 0.1;
          }
        }

        // TODO similarly as above, this algo needs rework in future
        int likeMinusDislike = likedCount - dislikedCount;
        double lmdRatio = 0;
        if (likeMinusDislike > 0) {
          lmdRatio = 0.9;
        } else {
          if (likeMinusDislike == 0) {
            lmdRatio = 0.5;
          } else {
            lmdRatio = 0.1;
          }
        }

        // XZ: it should add up to 100 in total
        final double chanceContributionWeightage = 50;
        final double completedVsSkippedContributionWeightage = 20;
        final double likeDislikeContributionWeightage = 30;

        double chanceContribution = chanceContributionWeightage * Math.random();
        double completedVsSkippedContribution = completedVsSkippedContributionWeightage * cmsRatio;
        double likeDislikeContribution = likeDislikeContributionWeightage * lmdRatio;

        // double selectedContribution    = 20; //TODO *WIP*
        // double freshnessContribution    = 20; //TODO *WIP*

        double points =
            chanceContribution + completedVsSkippedContribution + likeDislikeContribution;

        if (points > PASSING_GRADE) {
          tempList.add(t);
        }

        if (tempList.size() == 10) {
          break;
        }
      }
    }
    return tempList;
  }