public static Collection<Track> consigliDaSingoloTag(String tag) { Collection<Track> completeResult = Tag.getTopTracks(tag, codice); LinkedList<String> result = new LinkedList<>(); for (Track track : completeResult) { result.add(track.getName()); } return completeResult; }
public static Map<Tripla, HashSet<String>> costruisciMappa( Collection<Track> risultatiTop, int numSongInt) throws FileNotFoundException { FileOutputStream out; PrintStream ps; out = new FileOutputStream("myfile.txt"); ps = new PrintStream(out); Map<Tripla, HashSet<String>> result = new HashMap<Tripla, HashSet<String>>(); Iterator<Track> it = risultatiTop.iterator(); int i = 0; while (it.hasNext() && i < numSongInt) { Track currentTrack = it.next(); String currentArtist = currentTrack.getArtist(); String currentTitle = currentTrack.getName(); // .replace(',',' ').toUpperCase(); // String currentAlbum = currentTrack.getAlbum(); // int currentPlayCount = 0; int currentPlayCount = currentTrack.getPlaycount(); System.out.println(currentArtist + currentTitle + currentPlayCount); Tripla currentTripla = new Tripla(currentArtist, currentTitle, currentPlayCount); HashSet<String> currentTotalTags = new HashSet<String>(); Iterator<Tag> itTag = Track.getTopTags(currentArtist, currentTitle, codice).iterator(); // TODO metti la macro per il numero di tag da prendere while (itTag.hasNext() && currentTotalTags.size() < 5) { Tag currentTag = itTag.next(); int currentTagCount = currentTag.getCount(); String currentTagName = currentTag.getName().toLowerCase(); currentTotalTags.add(currentTagName); } result.put(currentTripla, currentTotalTags); i++; } /* System.out.println(result.size()); for(Entry<Tripla, HashSet<String>> currentEntry : result.entrySet()){ System.out.println(currentEntry.getKey().getTitolo()); System.out.println(currentEntry.getValue().toString()); } */ return result; }
public static HashMap<String, HashMap<String, Float>> associaPunteggioACanzoni( Map<String, Float> mappaPunteggioTag) { HashMap<String, HashMap<String, Float>> result = new HashMap<>(); for (String currentTag : mappaPunteggioTag.keySet()) { HashMap<String, Float> canzoniConsigliateDaSingoloTag = new HashMap<>(); Collection<Track> canzoniConsPaginatedResult = Tag.getTopTracks(currentTag, codice); for (Track track : canzoniConsPaginatedResult) { canzoniConsigliateDaSingoloTag.put(track.getName(), (mappaPunteggioTag.get(currentTag))); } } return result; }