<commit_before>import json

from flask import (
    render_template,
    request,
    make_response,
    Markup,
    abort,
    current_app,
    flash,
    redirect,
    url_for
)

import requests

from application import app, db
from .registry import registers, Register
from entry.representations import representations as _representations
from entry import Entry
from .utils import log_traceback


def link(register, field, value):
    return ('<a href="http://%s.%s/%s/%s">%s</a>'
            % (register, app.config['REGISTER_DOMAIN'], field, value, value))


# TBD: should be a register of filters for a Field/Datatype ..
@app.template_filter('datatype')
def datatype_filter(value, fieldname):

    # datatypes
    if fieldname == "sameAs":
        return Markup('<a href="%s">%s</a>' % (value, value))
    if fieldname == "hash":
        return Markup('<a href="/hash/%s">%s</a>' % (value, value))
    if fieldname == "name":
        return Markup('<a href="/name/%s">%s</a>' % (value, value))

    # link by register key - need to make this more general. but can't just
    # check for colon in string?
    if fieldname == "address":
        if ":" in value:
            register_name, key = value.split(":")
            return Markup(link(register_name, register_name, key))
        else:
            return Markup(link("address", "address", value))


    # link by name
    if fieldname == "addressCountry":
        return Markup(link("country", "addressCountry", value))
    if fieldname == "register":
        return Markup(link("register", "register", value))
    if fieldname == "field":
        return Markup(link("field", "field", value))
    if fieldname == "fields":
        return Markup([link('field', 'field', v) for v in value])

    return value


@app.template_filter('thousands_comma')
def thousands_comma_filter(value):
    if value:
        return "{:,d}".format(value)<commit_msg>flake you are too fussy<commit_after>import json

from flask import (
    render_template,
    request,
    make_response,
    Markup,
    abort,
    current_app,
    flash,
    redirect,
    url_for
)

import requests

from application import app, db
from .registry import registers, Register
from entry.representations import representations as _representations
from entry import Entry
from .utils import log_traceback


def link(register, field, value):
    return ('<a href="http://%s.%s/%s/%s">%s</a>'
            % (register, app.config['REGISTER_DOMAIN'], field, value, value))


# TBD: should be a register of filters for a Field/Datatype ..
@app.template_filter('datatype')
def datatype_filter(value, fieldname):

    # datatypes
    if fieldname == "sameAs":
        return Markup('<a href="%s">%s</a>' % (value, value))
    if fieldname == "hash":
        return Markup('<a href="/hash/%s">%s</a>' % (value, value))
    if fieldname == "name":
        return Markup('<a href="/name/%s">%s</a>' % (value, value))

    # link by register key - need to make this more general. but can't just
    # check for colon in string?
    if fieldname == "address":
        if ":" in value:
            register_name, key = value.split(":")
            return Markup(link(register_name, register_name, key))
        else:
            return Markup(link("address", "address", value))

    # link by name
    if fieldname == "addressCountry":
        return Markup(link("country", "addressCountry", value))
    if fieldname == "register":
        return Markup(link("register", "register", value))
    if fieldname == "field":
        return Markup(link("field", "field", value))
    if fieldname == "fields":
        return Markup([link('field', 'field', v) for v in value])

    return value


@app.template_filter('thousands_comma')
def thousands_comma_filter(value):
    if value:
        return "{:,d}".format(value)
{'fraction_non_alphanumeric': 0.14065359477124184, 'fraction_numerical': 0.0, 'mean_word_length': 3.167755991285403, 'pattern_counts': {'":': 20, '<': 19, '<?xml version=': 0, '>': 19, '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': '3583121', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1139, 'n_words': 345}