Ejemplo n.º 1
0
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel)
        {
            FastIDSet set = new FastIDSet();

            foreach (long num in preferredItemIDs)
            {
                set.addAll(this.similarity.allSimilarItemIDs(num));
            }
            set.removeAll(preferredItemIDs);
            return(set);
        }
Ejemplo n.º 2
0
        protected FastIDSet getAllOtherItems(long[] theNeighborhood, long theUserID)
        {
            DataModel model = this.getDataModel();
            FastIDSet set   = new FastIDSet();

            foreach (long num in theNeighborhood)
            {
                set.addAll(model.getItemIDsFromUser(num));
            }
            set.removeAll(model.getItemIDsFromUser(theUserID));
            return(set);
        }
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel)
        {
            FastIDSet          set        = new FastIDSet(dataModel.getNumItems());
            IEnumerator <long> enumerator = dataModel.getItemIDs();

            while (enumerator.MoveNext())
            {
                set.add(enumerator.Current);
            }
            set.removeAll(preferredItemIDs);
            return(set);
        }
Ejemplo n.º 4
0
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel)
        {
            FastIDSet set = new FastIDSet();

            foreach (long num in preferredItemIDs)
            {
                PreferenceArray array = dataModel.getPreferencesForItem(num);
                int             num2  = array.length();
                for (int i = 0; i < num2; i++)
                {
                    set.addAll(dataModel.getItemIDsFromUser(array.getUserID(i)));
                }
            }
            set.removeAll(preferredItemIDs);
            return(set);
        }
Ejemplo n.º 5
0
        protected override FastIDSet doGetCandidateItems(long[] preferredItemIDs, DataModel dataModel)
        {
            IEnumerator <long> enumerator = ((IEnumerable <long>)preferredItemIDs).GetEnumerator();

            if (preferredItemIDs.Length > this.maxItems)
            {
                double samplingRate = ((double)this.maxItems) / ((double)preferredItemIDs.Length);
                log.info("preferredItemIDs.Length {0}, samplingRate {1}", new object[] { preferredItemIDs.Length, samplingRate });
                enumerator = new SamplingLongPrimitiveIterator(enumerator, samplingRate);
            }
            FastIDSet possibleItemIDs = new FastIDSet();

            while (enumerator.MoveNext())
            {
                long            current = enumerator.Current;
                PreferenceArray array   = dataModel.getPreferencesForItem(current);
                int             num3    = array.length();
                if (num3 > this.maxUsersPerItem)
                {
                    FixedSizeSamplingIterator <Preference> iterator = new FixedSizeSamplingIterator <Preference>(this.maxUsersPerItem, array.GetEnumerator());
                    while (iterator.MoveNext())
                    {
                        this.addSomeOf(possibleItemIDs, dataModel.getItemIDsFromUser(iterator.Current.getUserID()));
                    }
                }
                else
                {
                    for (int i = 0; i < num3; i++)
                    {
                        this.addSomeOf(possibleItemIDs, dataModel.getItemIDsFromUser(array.getUserID(i)));
                    }
                }
            }
            possibleItemIDs.removeAll(preferredItemIDs);
            return(possibleItemIDs);
        }