<commit_before>"""
Format a set of INDRA Statements into an HTML-formatted report which also
supports curation.
"""
from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import re
import itertools
from os.path import abspath, dirname, join
from jinja2 import Template
from indra.statements import *
from indra.assemblers.english import EnglishAssembler
from indra.databases import get_identifiers_url


# Create a template object from the template file, load once
template_path = join(dirname(abspath(__file__)), 'template.html')
with open(template_path, 'rt') as f:
    template_str = f.read()
    template = Template(template_str)


class HtmlAssembler(object):
    """Generates an HTML-formatted report from INDRA Statements.

    The HTML report format includes statements formatted in English
    (by the EnglishAssembler), text and metadata for the Evidence
    object associated with each Statement, and a Javascript-based curation
    interface linked to the INDRA database (access permitting).

    Parameters
    ----------
    stmts : Optional[list[indra.statements.Statement]]
        A list of INDRA Statements to be added to the assembler.
    rest_api_results : dict
        Dictionary of query metadata provided by the INDRA REST API. Default
        is None.

    Attributes
    ----------
    statements : list[indra.statements.Statement]
        A list of INDRA Statements to assemble.
    model : str
        The HTML report formatted as a single string.
    rest_api_results : dict
        Dictionary of query metadata provided by the INDRA REST API.
    """
    def __init__(self, stmts=None, rest_api_results=None):
        if stmts is None:
            self.statements = []
        else:
            self.statements = stmts
        if rest_api_results is None:<commit_msg>Added more detail to description of the HTML interface.<commit_after>"""
Format a set of INDRA Statements into an HTML-formatted report which also
supports curation.
"""
from __future__ import absolute_import, print_function, unicode_literals
from builtins import dict, str
import re
import itertools
from os.path import abspath, dirname, join
from jinja2 import Template
from indra.statements import *
from indra.assemblers.english import EnglishAssembler
from indra.databases import get_identifiers_url


# Create a template object from the template file, load once
template_path = join(dirname(abspath(__file__)), 'template.html')
with open(template_path, 'rt') as f:
    template_str = f.read()
    template = Template(template_str)


class HtmlAssembler(object):
    """Generates an HTML-formatted report from INDRA Statements.

    The HTML report format includes statements formatted in English
    (by the EnglishAssembler), text and metadata for the Evidence
    object associated with each Statement, and a Javascript-based curation
    interface linked to the INDRA database (access permitting). The interface
    allows for curation of statements at the evidence level by letting the
    user specify type of error and (optionally) provide a short description of
    of the error.

    Parameters
    ----------
    stmts : Optional[list[indra.statements.Statement]]
        A list of INDRA Statements to be added to the assembler.
    rest_api_results : dict
        Dictionary of query metadata provided by the INDRA REST API. Default
        is None.

    Attributes
    ----------
    statements : list[indra.statements.Statement]
        A list of INDRA Statements to assemble.
    model : str
        The HTML report formatted as a single string.
    rest_api_results : dict
        Dictionary of query metadata provided by the INDRA REST API.
    """
    def __init__(self, stmts=None, rest_api_results=None):
        if stmts is None:
            self.statements = []
        else:
            self.statements = stmts
        if rest_api_results is None:
{'fraction_non_alphanumeric': 0.06428571428571428, 'fraction_numerical': 0.0005102040816326531, 'mean_word_length': 3.299342105263158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7039184', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1030, 'n_words': 424}