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; }