{% extends "base.html" %}

{% block gcontent %}
    {% if form is defined %}
        {{ render_form(form) }}
    {% endif %}

    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">Grounding Results for <code>{{ text }}</code></h3>
        </div>
        <div class="panel-body">
            {% if context %}
            <p>
                Using context: <i>{{ context }}</i>
            </p>
            {% endif %}
            <p>
                The table below contains the retrieved Groundings ordered by decreasing
                score. The standard name for the entry is given in the Name column.
                Additional groundings are provided for some entries where a match was
                found to an equivalent term in a namespace different from the primary
                grounding's.
            </p>
        </div>
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th>Grounding</th>
                <th>Name</th>
                <th>Score</th>
                <th>Additional Groundings</th>
            </tr>
            </thead>
            <tbody>
            {% for match in matches %}
                <tr>
                    {% set match_curie = match.term.get_curie() %}
                    <td>
                        <a class="label label-primary" href="{{ match['url'] }}">
                            {{ match_curie }}
                        </a>
                    </td>
                    <td>{{ match['term']['entry_name'] }}</td>
                    <td class="text-right">{{ match['score'] | round(4) }}</td>
                    <td>
                        {% for xref_curie, xref_url in match.get_grounding_dict().items() %}
                            {% if xref_curie != match_curie %}
                                <a class="label label-info" href="{{ xref_url }}">
                                    {{ xref_curie }}
                                </a>
                            {% endif %}
                        {% endfor %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}
