<commit_before>import re

from django.db.models import F, Q
import zephyr.models

# Match multi-word string between @** ** or match any one-word
# sequences after @
find_mentions = r'(?<![^\s\'\"\(,:<])@(?:\*\*([^\*]+)\*\*|(\w+))'
find_mentions_re = re.compile(find_mentions)

wildcards = ['all', 'everyone']

def find_user_for_mention(mention, realm):
    if mention in wildcards:
        return (True, None)

    try:
        user = zephyr.models.UserProfile.objects.filter(
                Q(full_name__iexact=mention) | Q(short_name__iexact=mention),
                realm=realm<commit_msg>Don't compile an unused copy of the find_mentions regex.<commit_after>import re

from django.db.models import F, Q
import zephyr.models

# Match multi-word string between @** ** or match any one-word
# sequences after @
find_mentions = r'(?<![^\s\'\"\(,:<])@(?:\*\*([^\*]+)\*\*|(\w+))'

wildcards = ['all', 'everyone']

def find_user_for_mention(mention, realm):
    if mention in wildcards:
        return (True, None)

    try:
        user = zephyr.models.UserProfile.objects.filter(
                Q(full_name__iexact=mention) | Q(short_name__iexact=mention),
                realm=realm
{'fraction_non_alphanumeric': 0.16694772344013492, 'fraction_numerical': 0.0, 'mean_word_length': 3.3962962962962964, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3704428', 'n_tokens_mistral': 423, 'n_tokens_neox': 407, 'n_words': 89}