Exemple #1
0
        protected int SampleOtherItemId(int userId, Hashtable itemsTable, int[] itemIds, Core.Random random)
        {
            // an item which has not been rated by a user
            int otherItemId = itemIds[random.Next(itemIds.Length)];

            while (itemsTable.ContainsKey(otherItemId))
            {
                otherItemId = itemIds[random.Next(itemIds.Length)];
            }
            return(otherItemId);
        }
Exemple #2
0
        protected Tuple <int, int, int> SampleItemPair(int userId, Hashtable itemsTable, int[] itemIds, Core.Random random)
        {
            // an item rated by a user
            int itemId = itemIds[random.Next(itemIds.Length)];

            while (!itemsTable.ContainsKey(itemId))
            {
                itemId = itemIds[random.Next(itemIds.Length)];
            }

            // an item which has not been rated by a user
            int otherItemId = itemIds[random.Next(itemIds.Length)];

            while (itemsTable.ContainsKey(otherItemId))
            {
                otherItemId = itemIds[random.Next(itemIds.Length)];
            }
            return(Tuple.Create(userId, itemId, otherItemId));
        }