Package Database.Primitives

Examples of Database.Primitives.Song


    private void formatSong(String dataLine) {
        //song\trating
        int[] splitData = strArrayToIntArray(dataLine.split("\t"));
        if (splitData.length == 2) {
            Song newSong;
            if (songs.containsSong(splitData[0])) {
                newSong = songs.getSong(splitData[0]);
                newSong.addRating(splitData[1]);
            } else {
                newSong = new Song(splitData[0], splitData[1]);
            }
            songs.addSong(newSong);

            currentUser.addRating(new Song(splitData[0], splitData[1]));

        } else {
            //System.err.println("Unexpected format for song line: " + dataLine);
        }
    }
View Full Code Here


        String[] data = dataLine.split("[ \t]");
        if (data.length != 3) {
    System.err.println("Split dataline into "+data.length+" pieces.");
          System.exit(1);
        }
        Song main = songs.getSong(Integer.parseInt(data[0]));
        if (main == null) {
            System.err.println("Could not find song with id:"+Integer.parseInt(data[0]));
        }
  Song other = songs.getSong(Integer.parseInt(data[1]));
        if (other == null) {
            System.err.println("Could not find other song id:"+Integer.parseInt(data[1]));
        }
        double neighborSim = Double.parseDouble(data[2]);
        Similarity sim = new Similarity(other, neighborSim);
View Full Code Here

    private void formatSimilarity(String dataLine) {
        String[] splitData = dataLine.split("\t");
        if ((splitData != null) && (splitData.length == 3)) {
            int neighborID = Integer.parseInt(splitData[1]);
            Song neighbor = songs.getSong(neighborID);
            if (neighbor == null) {
                System.err.println("Reading Neighborhood database found Song that wasn't already constructed.  Exiting.");
                System.exit(1);
            }
            double neighborSim = Double.parseDouble(splitData[2]);
View Full Code Here

            for (Song s : songs) {
//        forall neighborhood_i Union items_rated_by_user(active) item
                double numerator = 0, denominator = 0, predictedRating;
                for (Song ratedByActive : active.getRatings()) {
                    if (s.getNeighborhood().contains(ratedByActive) && !active.rated(s)) {
                        Song rba = songs.getSong(ratedByActive.getID());
                        double similarity = rba.getSimilarity(s);
//                numerator += math ... similarity(i, item) * active.rating(item) …
                        numerator += similarity * active.getRating(rba);
//                denominator += |similarity(i, item)|                   
                        denominator += Math.abs(similarity);
                    }
View Full Code Here

TOP

Related Classes of Database.Primitives.Song

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.