<commit_before>from .simplification import simplify

from ppp_datamodel.communication import TraceItem, Response


def traverse_until_fixpoint(predicate, tree):
    """Traverses the tree again and again until it is not modified."""
    old_tree = None
    tree = simplify(tree)
    while tree and old_tree != tree:
        old_tree = tree
        tree = tree.traverse(predicate)
        if not tree:
            return None
        tree = simplify(tree)
    return tree


def answer(request, tree, measures, module_name):
    trace = request.trace + [TraceItem(module_name, tree, measures)]
    return Response(request.language, tree, measures, trace)
<commit_msg>Improve name of build_answer.<commit_after>from .simplification import simplify

from ppp_datamodel.communication import TraceItem, Response


def traverse_until_fixpoint(predicate, tree):
    """Traverses the tree again and again until it is not modified."""
    old_tree = None
    tree = simplify(tree)
    while tree and old_tree != tree:
        old_tree = tree
        tree = tree.traverse(predicate)
        if not tree:
            return None
        tree = simplify(tree)
    return tree


def build_answer(request, tree, measures, module_name):
    trace = request.trace + [TraceItem(module_name, tree, measures)]
    return Response(request.language, tree, measures, trace)

{'fraction_non_alphanumeric': 0.08074074074074074, 'fraction_numerical': 0.0, 'mean_word_length': 3.400651465798046, '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': '4523047', 'n_tokens_mistral': 388, 'n_tokens_neox': 368, 'n_words': 123}