def facet(review, product, user, facet_type): facet_type = facet_type.lower() if facet_type == 'none': return 'all' elif facet_type == 'age': return get_age_group(user, review) else: raise ValueError('Invalid facet type')
def main(): counts = defaultdict(int) for line in sys.stdin: user = json.loads(line) age_group = get_age_group(user) counts[age_group] += 1 print '"age_group","count"' for age_group, count in counts.iteritems(): print '"{0}","{1}"'.format(age_group, count)