コード例 #1
0
ファイル: geo.py プロジェクト: srravula1/web-tools
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
ファイル: tags.py プロジェクト: no-wa-ke/MediaCloud-Web-Tools
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)
コード例 #5
0
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)
コード例 #6
0
ファイル: tags.py プロジェクト: srravula1/web-tools
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)
コード例 #7
0
ファイル: tags.py プロジェクト: c4fcm/MediaMeter-TopicMapper
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)
コード例 #8
0
ファイル: tags.py プロジェクト: c4fcm/MediaMeter-TopicMapper
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)
コード例 #9
0
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)
コード例 #10
0
ファイル: tags.py プロジェクト: no-wa-ke/MediaCloud-Web-Tools
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)
コード例 #11
0
ファイル: tags.py プロジェクト: no-wa-ke/MediaCloud-Web-Tools
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)
コード例 #12
0
ファイル: tags.py プロジェクト: no-wa-ke/MediaCloud-Web-Tools
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)
コード例 #13
0
ファイル: tags.py プロジェクト: c4fcm/MediaMeter-TopicMapper
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)
コード例 #14
0
ファイル: tags.py プロジェクト: c4fcm/MediaMeter-TopicMapper
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)
コード例 #15
0
ファイル: tags.py プロジェクト: c4fcm/MediaMeter-TopicMapper
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)
コード例 #16
0
ファイル: geo.py プロジェクト: srravula1/web-tools
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)