Exemple #1
0
def partial_relations(p, relations):
    larger = []
    smaller = []
    for relation,words in relations.iteritems():
        if 'part' in relation:
            type = 'part'
        elif 'substance' in relation:
            type = 'substance'
        elif 'member' in relation:
            type = 'member'
        else:
            type = 'kind'
        if 'hyper' in relation or 'holo' in relation:
            type += '-larger'
            larger.extend([(w, type) for w in words])
        else:
            type += '-smaller'
            smaller.extend([(w, type) for w in words])
    if len(larger) > 0 or len(smaller) > 0:
        with p(html.table()):
            with p(html.tr()):
                with p(html.td({'width':'50%', 'valign':'top'})):
                    q=[link_to_synset(s, type=t) for s,t in smaller]
                    p(u', '.join(q))
                with p(html.td({'width':'50%', 'valign':'top'})):
                    q=[link_to_synset(s, type=t) for s,t in larger]
                    p(u', '.join(q))
Exemple #2
0
def partial_result(p, query, result, synonyms, definition, relations, images):
    with p(html.table({'style':'margin:20px;width:100%;'})):
        with p(html.tr()):
            with p(html.td({'valign':'top', 'width':'50%'})):
                p(partial_result_data(query, result, synonyms, definition, relations))
                p(html.nobreaks(' '))
            with p(html.td({'valign':'top', 'width':'50%'})):
                p(template_image_table(images))
                p(html.nobreaks(' '))
Exemple #3
0
def partial_result_data(p, query, result, synonyms, definition, relations):
    with p(html.table()):
        with p(html.tr()):
            with p(html.td()):
                max_count = max(c for _,c in synonyms)
                s = [helper_synonym(query, l, c, max_count) for l,c in synonyms]
                p(', '.join(s))
        with p(html.tr()):
            with p(html.td()):
                p(partial_definition(definition))
        with p(html.tr()):
            with p(html.td()):
                p(partial_relations(relations))
Exemple #4
0
def template_image_table(p, images):
    with p(html.table()):
        with p(html.tr()):
            with p(html.td()):
                if len(images) > 0:
                    p(helper_linked_preview_image(images[0]))
            with p(html.td()):
                if len(images) > 1:
                    p(helper_linked_preview_image(images[1]))
        with p(html.tr()):
            with p(html.td()):
                if len(images) > 2:
                    p(helper_linked_preview_image(images[2]))
            with p(html.td()):
                if len(images) > 3:
                    p(helper_linked_preview_image(images[3]))