<commit_before>from django.dispatch import Signal, receiver
from django.core.mail import EmailMultiAlternatives
from search.models import Person
import logging
from django.conf import settings

unknown_tag_signal = Signal(providing_args=['author', 'title', 'tags'])
logger = logging.getLogger('search')


@receiver(unknown_tag_signal)
def unknown_tag_callback(sender, **kwargs):
    author = Person.objects.get(pk=kwargs['author'])
    title = kwargs['title']
    unknown_tags = kwargs['tags']
    message = "{person} created an item '{title}'".format(person=author.name,
                                                          title=title) + \
              "and tried to add the following nonexisting tags:\n" + \
              "Tokens: " + ','.join(unknown_tags['token']) + "\n" + \
              "Persons: " + ','.join(unknown_tags['person']) + "\n" + \
              "Literals: " + ','.join(unknown_tags['literal']) + "\n\n" + \
              "This message was generated automatically."
    logger.debug(message)
    subject = 'User {person} uses unknown tags'.format(person=author.name)
    from_email = "notifications@%s" % (settings.HOSTNAME,)
    msg = EmailMultiAlternatives(subject, message, from_email,
                                 to=settings.ADMIN_NOTIFICATION_EMAIL)
    msg.send(fail_silently=True)
<commit_msg>Altered message to moderator about unused tags<commit_after>from django.dispatch import Signal, receiver
from django.core.mail import EmailMultiAlternatives
from search.models import Person
import logging
from django.conf import settings

unknown_tag_signal = Signal(providing_args=['author', 'title', 'tags'])
logger = logging.getLogger('search')


@receiver(unknown_tag_signal)
def unknown_tag_callback(sender, **kwargs):
    author = Person.objects.get(pk=kwargs['author'])
    title = kwargs['title']
    unknown_tags = kwargs['tags']
    message = "Dear moderator,\n" + \
              "{person} created an item '{title}' ".format(person=author.name,
                                                          title=title) + \
              "and tried to add the following nonexisting tags:\n" + \
              "Tokens: " + ','.join(unknown_tags['token']) + "\n" + \
              "Persons: " + ','.join(unknown_tags['person']) + "\n" + \
              "Literals: " + ','.join(unknown_tags['literal']) + "\n\n" + \
              "It is up to you to determine whether these tags should " + \
              "exist and add them to both the system and this item." + \
              "\n\nThis message was generated automatically."
    logger.debug(message)
    subject = '[Starfish] User {person} uses unknown tags'.format(person=author.name)
    from_email = "notifications@%s" % (settings.HOSTNAME,)
    msg = EmailMultiAlternatives(subject, message, from_email,
                                 to=settings.ADMIN_NOTIFICATION_EMAIL)
    msg.send(fail_silently=True)

{'fraction_non_alphanumeric': 0.13128876636802206, 'fraction_numerical': 0.0, 'mean_word_length': 2.7848761408083442, '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': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '761053', 'n_tokens_mistral': 809, 'n_tokens_neox': 796, 'n_words': 192}