Beispiel #1
0
		/// <summary>Read the album data</summary>
		/// <param name="reader">a reader object to read the data from</param>
		/// <param name="items">the <see cref="KDDCupItems"/> object</param>
		static public void ReadAlbums(TextReader reader, KDDCupItems items)
		{
			string line;

			while ( (line = reader.ReadLine()) != null )
			{
				string[] tokens = line.Split('|');

				int album_id  = int.Parse(tokens[0]);
				int artist_id = tokens[1] == "None" ? -1 : int.Parse(tokens[1]);

				var genres = new int[tokens.Length - 2];
				for (int i = 0; i < genres.Length; i++)
					genres[i] = int.Parse(tokens[2 + i]);

				items.Insert(album_id, KDDCupItemType.Album, album_id, artist_id, genres);
			}
		}
Beispiel #2
0
		/// <summary>Read in the item data from several files</summary>
		/// <param name="tracks_filename">name of the tracks file</param>
		/// <param name="albums_filename">name of the album/record file</param>
		/// <param name="artists_filename">name of the artists file</param>
		/// <param name="genres_filename">name of the genre file</param>
		/// <param name="track_no">1 or 2</param>
		/// <returns>the rating data</returns>
		static public KDDCupItems Read(string tracks_filename, string albums_filename, string artists_filename, string genres_filename, uint track_no)
		{
			KDDCupItems items = new KDDCupItems(track_no == 1 ? 624961 : 296111);

			using ( var reader = new StreamReader(tracks_filename) )
				ReadTracks(reader, items);

			using ( var reader = new StreamReader(albums_filename) )
				ReadAlbums(reader, items);

			using ( var reader = new StreamReader(artists_filename) )
				ReadArtists(reader, items);

			using ( var reader = new StreamReader(genres_filename) )
				ReadGenres(reader, items);

			return items;
		}
Beispiel #3
0
		/// <summary>Read the genre data</summary>
		/// <param name="reader">a reader object to read the data from</param>
		/// <param name="items">the <see cref="KDDCupItems"/> object</param>
		static public void ReadGenres(TextReader reader, KDDCupItems items)
		{
			string line;

			while ( (line = reader.ReadLine()) != null )
			{
				int genre_id = int.Parse(line);

				items.Insert(genre_id, KDDCupItemType.Genre, -1, -1, null);
			}
		}
Beispiel #4
0
		/// <summary>Read the artist data</summary>
		/// <param name="reader">a reader object to read the data from</param>
		/// <param name="items">the <see cref="KDDCupItems"/> object</param>
		static public void ReadArtists(TextReader reader, KDDCupItems items)
		{
			string line;

			while ( (line = reader.ReadLine()) != null )
			{
				int artist_id = int.Parse(line);

				items.Insert(artist_id, KDDCupItemType.Artist, -1, artist_id, null);
			}
		}