예제 #1
0
파일: callbacks.py 프로젝트: cfalk/DuChemin
def _fetch_facet_results(request):
    s = DCSolrSearch(request)
    facet_params = {
        'facet_mincount': 1,
    }
    facet_res = s.facets(fq=['type:duchemin_analysis'], **facet_params)
    facets = facet_res.facet_counts['facet_fields']
    # filtered_facets = dict([(k, v) for k, v in facets.iteritems() if k in settings.DISPLAY_FACETS])

    filtered_facets = []
    for k, v in facets.iteritems():
        this_facet = []
        if k not in settings.DISPLAY_FACETS.keys():
            continue
        for facet_value, num in v.iteritems():
            if k == "book_id_title":
                facet_info = facet_value.split("_")
                this_facet.append([facet_info[1], settings.DISPLAY_FACETS[k][0], facet_info[0]])
            else:
                this_facet.append([facet_value, settings.DISPLAY_FACETS[k][0]])

        this_facet.sort()
        filtered_facets.append([settings.DISPLAY_FACETS[k][1], this_facet])

    filtered_facets.sort()

    print filtered_facets

    data = {
        'facet_results': filtered_facets
    }
    return render(request, 'search/facets.html', data)
예제 #2
0
파일: search.py 프로젝트: DuChemin/DuChemin
def _empty_search(request):
    s = DCSolrSearch(request)
    ret = s.facets(fq=['duchemin_analysis'], rows=0)

    facets = ret.facet_counts['facet_fields']
    cadence_alter = sorted(facets['cadence_alter'])
    book_title = sorted(facets['book_id_title'])
    cadence_final_tone = sorted(facets['cadence_final_tone'])
    cadence_kind = sorted(facets['cadence_kind'])
    composer = sorted(facets['composer'])
    contributor = sorted(facets['contributor'])
    is_cadence = sorted(facets['is_cadence'])
    repeat_kind = sorted(facets['repeat_kind'])
    text_treatment = sorted(facets['text_treatment'])

    book_info = sorted([tuple(book.split("_")) for book in book_title])

    cad_voice_cantz = [__construct_voice_facet(v, 'cadence_role_cantz', hidden=False) for v in VOICE_NAMES]
    cad_voice_tenz = [__construct_voice_facet(v, 'cadence_role_tenz') for v in VOICE_NAMES]

    intpatt_up6_voice = [__construct_voice_facet(v, 'intpatt_p6_up', hidden=False) for v in VOICE_NAMES]
    intpatt_lo6_voice = [__construct_voice_facet(v, 'intpatt_p6_lo') for v in VOICE_NAMES]

    intpatt_up3_voice = [__construct_voice_facet(v, 'intpatt_p3_up', hidden=False) for v in VOICE_NAMES]
    intpatt_lo3_voice = [__construct_voice_facet(v, 'intpatt_p3_lo') for v in VOICE_NAMES]

    intpatt_up53_voice = [__construct_voice_facet(v, 'intpatt_53_up', hidden=False) for v in VOICE_NAMES]
    intpatt_lo53_voice = [__construct_voice_facet(v, 'intpatt_53_lo') for v in VOICE_NAMES]

    prestype_nonim_up1 = [__construct_voice_facet(v, 'prestype_nim_up1', hidden=False) for v in VOICE_NAMES]
    prestype_nonim_lo1 = [__construct_voice_facet(v, 'prestype_nim_lo1') for v in VOICE_NAMES]
    prestype_nonim_up2 = [__construct_voice_facet(v, 'prestype_nim_up2') for v in VOICE_NAMES]
    prestype_nonim_lo2 = [__construct_voice_facet(v, 'prestype_nim_lo2') for v in VOICE_NAMES]

    prestype_free_dux = [__construct_voice_facet(v, 'prestype_free_dux', hidden=False) for v in VOICE_NAMES]
    prestype_free_comes = [__construct_voice_facet(v, 'prestype_free_comes') for v in VOICE_NAMES]

    prestype_imduet_dux1 = [__construct_voice_facet(v, 'prestype_imduet_dux1', hidden=False) for v in VOICE_NAMES]
    prestype_imduet_comes1 = [__construct_voice_facet(v, 'prestype_imduet_comes1') for v in VOICE_NAMES]
    prestype_imduet_dux2 = [__construct_voice_facet(v, 'prestype_imduet_dux2') for v in VOICE_NAMES]
    prestype_imduet_comes2 = [__construct_voice_facet(v, 'prestype_imduet_comes2') for v in VOICE_NAMES]

    prestype_entry_dux1 = [__construct_voice_facet(v, 'prestype_entry_p_dux1', hidden=False) for v in VOICE_NAMES]
    prestype_entry_comes1 = [__construct_voice_facet(v, 'prestype_entry_p_comes1') for v in VOICE_NAMES]
    prestype_entry_dux2 = [__construct_voice_facet(v, 'prestype_entry_p_dux2') for v in VOICE_NAMES]
    prestype_entry_comes2 = [__construct_voice_facet(v, 'prestype_entry_p_comes2') for v in VOICE_NAMES]

    prestype_entry_t_dux1 = [__construct_voice_facet(v, 'prestype_entry_t_dux1', hidden=False) for v in VOICE_NAMES]
    prestype_entry_t_comes1 = [__construct_voice_facet(v, 'prestype_entry_t_comes1') for v in VOICE_NAMES]
    prestype_entry_t_dux2 = [__construct_voice_facet(v, 'prestype_entry_t_dux2') for v in VOICE_NAMES]
    prestype_entry_t_comes2 = [__construct_voice_facet(v, 'prestype_entry_t_comes2') for v in VOICE_NAMES]

    prestype_entry_s_dux1 = [__construct_voice_facet(v, 'prestype_entry_s_dux1', hidden=False) for v in VOICE_NAMES]
    prestype_entry_s_comes1 = [__construct_voice_facet(v, 'prestype_entry_s_comes1') for v in VOICE_NAMES]
    prestype_entry_s_dux2 = [__construct_voice_facet(v, 'prestype_entry_s_dux2') for v in VOICE_NAMES]
    prestype_entry_s_comes2 = [__construct_voice_facet(v, 'prestype_entry_s_comes2') for v in VOICE_NAMES]

    data = {
        'book_info': book_info,
        'cadence_alters': cadence_alter,
        'cadence_final_tones': cadence_final_tone,
        'cadence_kinds': cadence_kind,
        'composers': composer,
        'contributors': contributor,
        'is_cadences': is_cadence,
        'repeat_kinds': repeat_kind,
        'text_treatments': text_treatment,
        'cad_voice_cantz': cad_voice_cantz,
        'cad_voice_tenz': cad_voice_tenz,
        'intpatt_up6_voice': intpatt_up6_voice,
        'intpatt_lo6_voice': intpatt_lo6_voice,
        'intpatt_up3_voice': intpatt_up3_voice,
        'intpatt_lo3_voice': intpatt_lo3_voice,
        'intpatt_up53_voice': intpatt_up53_voice,
        'intpatt_lo53_voice': intpatt_lo53_voice,
        'prestype_nonim_up1': prestype_nonim_up1,
        'prestype_nonim_lo1': prestype_nonim_lo1,
        'prestype_nonim_up2': prestype_nonim_up2,
        'prestype_nonim_lo2': prestype_nonim_lo2,
        'prestype_free_dux': prestype_free_dux,
        'prestype_free_comes': prestype_free_comes,
        'prestype_imduet_dux1': prestype_imduet_dux1,
        'prestype_imduet_comes1': prestype_imduet_comes1,
        'prestype_imduet_dux2': prestype_imduet_dux2,
        'prestype_imduet_comes2': prestype_imduet_comes2,
        'prestype_entry_dux1': prestype_entry_dux1,
        'prestype_entry_comes1': prestype_entry_comes1,
        'prestype_entry_dux2': prestype_entry_dux2,
        'prestype_entry_comes2': prestype_entry_comes2,
        'prestype_entry_t_dux1': prestype_entry_t_dux1,
        'prestype_entry_t_comes1': prestype_entry_t_comes1,
        'prestype_entry_t_dux2': prestype_entry_t_dux2,
        'prestype_entry_t_comes2': prestype_entry_t_comes2,
        'prestype_entry_s_dux1': prestype_entry_s_dux1,
        'prestype_entry_s_comes1': prestype_entry_s_comes1,
        'prestype_entry_s_dux2': prestype_entry_s_dux2,
        'prestype_entry_s_comes2': prestype_entry_s_comes2,
    }
    return render(request, 'search/search.html', data)