Curated recommendations are just random selections
333424
def recommend(self, client_data, limit, extra_data={}):
        
        guids = self._curated_wl.get_randomized_guid_sample(limit)

        results = [(guid, 1.0) for guid in guids]

        log_data = (client_data["client_id"], str(guids))
        self.logger.info(
            "Curated recommendations client_id: [%s], guids: [%s]" % log_data
        )
        return results
1305660
def create_all_recommendations(self, cores, ip_views=False):
        """"""
        global _store
        _store = self.store
        _create_all_recommendations(cores, ip_views, self.config)
785086
def select_random(ports=None, exclude_ports=None):
    
    if ports is None:
        ports = available_good_ports()

    if exclude_ports is None:
        exclude_ports = set()

    ports.difference_update(set(exclude_ports))

    for port in random.sample(ports, min(len(ports), 100)):
        if not port_is_used(port):
            return port
    raise PortForException("Can't select a port")
61081
function (callback) {
                var originalSuggestions = this._suggestions;
                var nbSuggestions = originalSuggestions.length;
                var returnedSuggestions = [];
                var suggestion;
                for (var index = 0; index < nbSuggestions; index++) {
                    suggestion = originalSuggestions[index];
                    returnedSuggestions.push(suggestion.original);
                }
                this.$callback(callback, returnedSuggestions);
            }
291322
def statistic_recommend(classes, P):
    
    if imbalance_check(P):
        return IMBALANCED_RECOMMEND
    if binary_check(classes):
        return BINARY_RECOMMEND
    return MULTICLASS_RECOMMEND
335641
function (suggestionsList, suggestion) {
                for (var i = 0, l = suggestionsList.length; i < l; i++) {
                    if (suggestion.label == suggestionsList[i].label) {
                        return i;
                    }
                }
                return -1;
            }
426716
def query_random(num=6, kind='1'):
        '''
        
        '''
        return TabWiki.select().where(
            TabWiki.kind == kind
        ).order_by(
            peewee.fn.Random()
        ).limit(num)
1315691
def parse_suggestions(soup):
    """"""
    selector_comps = {'class': 'companyData'}
    companies = soup.findAll('div', selector_comps)

    def is_exact_match(c):
        """Determines if this company suggestion has an [exact match]
        html label or whether its name matches the company name the
        user searched for
        """
        selector_exact = {'class' : 'chickletExactMatch chicklet'}
        searched_name = soup.findAll('input', {'name': 'sc.keyword'})[0]['value']
        actual_name = c.findAll('h3')[0].text
        names_match = searched_name.lower() == actual_name.lower()
        exact_tag = bool(c.findAll('i', selector_exact))
        return exact_tag or names_match

    def parse_suggestion(c):
        return {
            'name': c.findAll('h3')[0].text,
            'uri': c.findAll('a')[1]['href'],
            'exact': is_exact_match(c)
            }
    
    suggestions = []
    for c in companies:
        try:
            suggestions.append(parse_suggestion(c))
        except IndexError as e:
            pass
            
    return suggestions
80343
function () {
				var oView = this.getView(),
					// Collect all possible items from all lists
					aItems = [].concat(
						oView.byId("allList").getItems(),
						oView.byId("apiList").getItems(),
						oView.byId("documentationList").getItems(),
						oView.byId("samplesList").getItems()
					),
					iLen = aItems.length,
					oItem;

				while (iLen--) {
					oItem = aItems[iLen];
					// Access control lazy loading method if available
					if (oItem._getLinkSender) {
						// Set link href to allow open in new window functionality
						oItem._getLinkSender().setHref("#/" + oItem.getCustomData()[0].getValue());
					}
				}
			}
1128645
def get_random_ontology(TOP_RANGE=10, pattern=""):
    """"""
    choices = get_localontologies(pattern=pattern)
    try:
        ontouri = choices[random.randint(0, TOP_RANGE)]  # [0]
    except:
        ontouri = choices[0]
    print("Testing with URI: %s" % ontouri)
    g = get_pickled_ontology(ontouri)
    if not g:
        g = do_pickle_ontology(ontouri)
    return ontouri, g
642536
public function recommlistarts()
    {
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_rssRecommListArts')) {
            $oRecommList = oxNew(\OxidEsales\Eshop\Application\Model\RecommendationList::class);
            if ($oRecommList->load(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('recommid'))) {
                $this->_getRssFeed()->loadRecommListArticles($oRecommList);

                return;
            }
        }
        error_404_handler();
    }
354753
def query_all():
        '''
        
        '''
        recs = TabPost2Tag.select(
            TabPost2Tag,
            TabTag.kind.alias('tag_kind'),
        ).join(
            TabTag,
            on=(TabPost2Tag.tag_id == TabTag.uid)
        )
        return recs
1037889
def weighted_random_choice(items):
    
    l = list(items)
    r = random.random() * sum([i[1] for i in l])
    for x, p in l:
        if p > r:
            return x
        r -= p
    return None
1029276
def suggestion_list(inp, options):
    
    options_by_distance = OrderedDict()
    input_threshold = len(inp) / 2

    for option in options:
        distance = lexical_distance(inp, option)
        threshold = max(input_threshold, len(option) / 2, 1)
        if distance <= threshold:
            options_by_distance[option] = distance

    return sorted(
        list(options_by_distance.keys()), key=lambda k: options_by_distance[k]
    )
497550
def select(self, table, items=None, limit=None, offset=None, remote_filter=None, func_filters=None):
        '''
        '''
        self._table = table

        if remote_filter:
            if not isinstance(remote_filter, tuple):
                raise TypeError("{0} must be of type <type tuple>".format(remote_filter))

            table = "%s(%s)" %(table, ','.join(map(str, remote_filter)))

        if not items:
            items = ['*']
        self._query = "SELECT {1} FROM {0} ".format(table, ','.join(items))

        if func_filters:
            self._func = self._func_filters(func_filters) 

        self._limit = limit
        self._offset = offset
            
        return self
287786
def recommend(self, limit=10):
        '''
        
        '''
        expected_list = [(arm_id, beta_dist.expected_value()) for arm_id, beta_dist in self.__beta_dist_dict.items()]
        expected_list = sorted(expected_list, key=lambda x: x[1], reverse=True)
        return expected_list[:limit]
978370
function (suggestionToBeAdded) {
                var allSuggestions = ariaUtilsJson.copy(this.selectedSuggestions, false);
                var res = [];
                var maxOptions = this.maxOptions;
                var length = suggestionToBeAdded.length;
                if (maxOptions && allSuggestions.length + length > maxOptions) {
                    length = maxOptions - allSuggestions.length;
                }
                if (length > 0) {
                    for (var k = 0; k < length; k++) {
                        if (this._editedSuggestionIndex != -1) {
                            allSuggestions.splice(this._editedSuggestionIndex, 0, suggestionToBeAdded[k]);
                            this._editedSuggestionIndex += 1;
                        } else {
                            allSuggestions.push(suggestionToBeAdded[k]);
                        }
                        res[k] = suggestionToBeAdded[k];
                    }
                    this._editedSuggestionIndex = -1;
                    this.selectedSuggestions = allSuggestions;
                }
                return res;
            }