func (this *GenericUserBasedRecommender) getAllOtherItemIds(neighborhoods []uint64, userId uint64) ([]uint64, error) { possibleIdSet := utils.IdSet{} for _, uid := range neighborhoods { userPrefs, err := this.dataModel.GetUserPreferences(uid) if err != nil { continue } possibleIdSet.AddArray(userPrefs.Ids()) } userPrefs, err := this.dataModel.GetUserPreferences(userId) if err != nil { return nil, err } possibleIdSet.RemoveArray(userPrefs.Ids()) return possibleIdSet.ToArray(), nil }
func (this *GenericItemBasedRecommender) getAllOtherItemIds(preferredItemIds []uint64, dataModel model.DataModel) ([]uint64, error) { possibleIdSet := utils.IdSet{} for _, itemId := range preferredItemIds { itemPrefs, err := dataModel.GetItemPreferences(itemId) if err != nil { continue } for _, uid := range itemPrefs.Ids() { up, err := dataModel.GetUserPreferences(uid) if err != nil { continue } possibleIdSet.AddArray(up.Ids()) } } possibleIdSet.RemoveArray(preferredItemIds) return possibleIdSet.ToArray(), nil }