def filter_articles(candidates, reasons):
    """Filter articles to allowed set for recommendations.

    Criteria:
    * Not disambiguation page
    * Has associated Wikidata item
    * No existing description (either via Wikidata or local shortdesc)
    * Not protected in any way
    """
    filtered_candidates = {}
    for c in candidates:
        if 'pageprops' not in c:
            print("Missing pageprops:", c)
            reasons['missing'] += 1
            continue
        elif 'disambiguation' in c['pageprops']:
            reasons['disambiguation'] += 1
            continue
        elif not 'wikibase_item' in c['pageprops']:
            reasons['wikibase_missing'] += 1
            continue
        elif 'description' in c:
            reasons['has_description'] += 1
            continue
        elif c['protection']:
            reasons['protected'] += 1
            continue
        else:
            filtered_candidates[c['pageid']] = c
    return filtered_candidates