public static boolean writeWikiSample(BookmarkReader reader, List<Bookmark> userSample, String filename, List<int[]> catPredictions) {
		try {
			FileWriter writer = new FileWriter(new File("./data/csv/" + filename + ".txt"));
			BufferedWriter bw = new BufferedWriter(writer);
			int userCount = 0;
			// TODO: check encoding
			for (Bookmark bookmark : userSample) {
				bw.write("\"" + reader.getUsers().get(bookmark.getUserID()).replace("\"", "") + "\";");
				bw.write("\"" + reader.getResources().get(bookmark.getWikiID()).replace("\"", "") + "\";");
				bw.write("\"" + bookmark.getTimestamp().replace("\"", "") + "\";\"");
				int i = 0;
				for (int tag : bookmark.getTags()) {
					bw.write(URLEncoder.encode(reader.getTags().get(tag).replace("\"", ""), "UTF-8"));
					if (++i < bookmark.getTags().size()) {
						bw.write(',');
					}					
				}
				bw.write("\";\"");
				
				List<Integer> userCats = (catPredictions == null ? 
						bookmark.getCategories() : Ints.asList(catPredictions.get(userCount++)));
				i = 0;
				for (int cat : userCats) {
					bw.write(URLEncoder.encode((catPredictions == null ? reader.getCategories().get(cat).replace("\"", "") : reader.getTags().get(cat)).replace("\"", ""), "UTF-8"));
					if (++i < userCats.size()) {
						bw.write(',');
					}					
				}
				bw.write("\"");
				if (bookmark.getRating() != -2) {
					bw.write(";\"" + bookmark.getRating() + "\"");
				}
				bw.write("\n");
			}
			
			bw.flush();
			bw.close();
			return true;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return false;
	}