def explorer_geo_csv(): filename = 'sampled-geographic-coverage' data = request.form query_object = json.loads(data['q']) solr_q, solr_fq = parse_query_with_keywords(query_object) filename = file_name_for_download(query_object['label'], filename) data = apicache.top_tags_with_coverage(solr_q, solr_fq, tags.GEO_TAG_SET) props = ['tags_id', 'label', 'count', 'pct'] return csv.stream_response(data['results'], props, filename)
def api_explorer_demo_geotag_count(): search_id = int( request.args['search_id']) if 'search_id' in request.args else None if search_id not in [None, -1]: solr_q, solr_fq = parse_as_sample(search_id, request.args['index']) else: solr_q, solr_fq = parse_query_with_keywords(request.args) data = apicache.top_tags_with_coverage(solr_q, solr_fq, tags.GEO_TAG_SET) data['results'] = _filter_for_countries(data['results']) return jsonify(data)
def demo_top_tags_with_coverage(tag_sets_id,): # parses the query for you search_id = int(request.args['search_id']) if 'search_id' in request.args else None if search_id not in [None, -1]: sample_searches = load_sample_searches() current_search = sample_searches[search_id]['queries'] solr_q, solr_fq = parse_query_with_args_and_sample_search(request.args, current_search) else: solr_q, solr_fq = parse_query_with_keywords(request.args) return apicache.top_tags_with_coverage(solr_q, solr_fq, tag_sets_id)
def demo_top_tags_with_coverage(tag_sets_id, ): # parses the query for you search_id = int( request.args['search_id']) if 'search_id' in request.args else None query_index = int( request.args['index']) if 'index' in request.args else None if (query_index is None) and (search_id not in [None, -1]): solr_q, solr_fq = parse_as_sample(search_id, request.args) else: solr_q, solr_fq = parse_query_with_keywords(request.args) return apicache.top_tags_with_coverage(solr_q, solr_fq, tag_sets_id)
def api_explorer_demo_geotag_count(): search_id = int(request.args['search_id']) if 'search_id' in request.args else None if search_id not in [None, -1]: SAMPLE_SEARCHES = load_sample_searches() current_search = SAMPLE_SEARCHES[search_id]['queries'] solr_q, solr_fq = parse_query_with_args_and_sample_search(request.args, current_search) else: solr_q, solr_fq= parse_query_with_keywords(request.args) data = apicache.top_tags_with_coverage(solr_q, solr_fq, tags.GEO_TAG_SET) data['results'] = _filter_for_countries(data['results']) return jsonify(data)
def explorer_entities_csv(tag_sets_id): tag_set = base_apicache.tag_set(tag_sets_id) filename = 'sampled-{}'.format(tag_set['label']) data = request.form query_object = json.loads(data['q']) solr_q, solr_fq = parse_query_with_keywords(query_object) filename = file_name_for_download(query_object['label'], filename) top_tag_counts = apicache.top_tags_with_coverage( solr_q, solr_fq, tag_sets_id, TAG_COUNT_DOWNLOAD_LENGTH)['results'] return csv.stream_response(top_tag_counts, ENTITY_DOWNLOAD_COLUMNS, filename)
def demo_top_tags_with_coverage(tag_sets_id,): # parses the query for you search_id = int(request.args['search_id']) if 'search_id' in request.args else None query_index = int(request.args['index']) if 'index' in request.args else None if (query_index is None )and (search_id not in [None, -1]): sample_searches = load_sample_searches() current_search = sample_searches[search_id]['queries'] solr_q, solr_fq = parse_as_sample(search_id, request.args) else: solr_q, solr_fq = parse_query_with_keywords(request.args) return apicache.top_tags_with_coverage(solr_q, solr_fq, tag_sets_id)
def explorer_entities_csv(tag_sets_id): tag_set = apicache.tag_set(tag_sets_id) filename = 'sampled-{}'.format(tag_set['label']) data = request.form if 'searchId' in data: solr_q, solr_fq = parse_as_sample(data['searchId'], data['index']) else: query_object = json.loads(data['q']) solr_q, solr_fq = parse_query_with_keywords(query_object) filename = file_name_for_download(query_object['label'], filename) top_tag_counts = apicache.top_tags_with_coverage(solr_q, solr_fq, tag_sets_id, TAG_COUNT_DOWNLOAD_LENGTH)['results'] return csv.stream_response(top_tag_counts, ENTITY_DOWNLOAD_COLUMNS, filename)
def explorer_geo_csv(): filename = u'sampled-geographic-coverage' data = request.form if 'searchId' in data: solr_q, solr_fq = parse_as_sample(data['searchId'], data['index']) else: query_object = json.loads(data['q']) solr_q, solr_fq = parse_query_with_keywords(query_object) filename = file_name_for_download(query_object['label'], filename) data = apicache.top_tags_with_coverage(solr_q, solr_fq, tags.GEO_TAG_SET) data['results'] = _filter_for_countries(data['results']) props = ['label', 'count', 'pct', 'alpha3', 'iso-a2', 'geonamesId', 'tags_id', 'tag'] return csv.stream_response(data['results'], props, filename)
def top_themes(): solr_q, solr_fq = parse_query_with_keywords(request.args) results = apicache.top_tags_with_coverage(solr_q, solr_fq, NYT_LABELS_TAG_SET_ID) return jsonify(results)
def top_entities_organizations(): solr_q, solr_fq = parse_query_with_keywords(request.args) results = apicache.top_tags_with_coverage(solr_q, solr_fq, CLIFF_ORGS) return jsonify(results)
def top_entities_people(): solr_q, solr_fq = parse_query_with_keywords(request.args) results = apicache.top_tags_with_coverage(solr_q, solr_fq, CLIFF_PEOPLE) return jsonify(results)
def api_explorer_geotag_count(): solr_q, solr_fq = parse_query_with_keywords(request.form) data = apicache.top_tags_with_coverage(solr_q, solr_fq, tags.GEO_TAG_SET) return jsonify(data)