<commit_before>import re

from django.db.models import get_model
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse

from ..models import Tag, TaggedItem
from ..utils import LINEAR, LOGARITHMIC


register = Library()

tag_ref_re = re.compile("(^|\s)#(\w+)")

class TagsForModelNode(Node):
    def __init__(self, model, context_var, counts):
        self.model = model
        self.context_var = context_var
        self.counts = counts

    def render(self, context):
        model = get_model(*self.model.split('.'))
        if model is None:
            raise TemplateSyntaxError(_('tags_for_model tag was given an invalid model: %s') % self.model)
        context[self.context_var] = Tag.objects.usage_for_model(model, counts=self.counts)
        return ''


class TagCloudForModelNode(Node):
    def __init__(self, model, context_var, **kwargs):
        self.model = model
        self.context_var = context_var
        self.kwargs = kwargs

    def render(self, context):
        model = get_model(*self.model.split('.'))
        if model is None:<commit_msg>fix tags with symbol inside<commit_after>import re

from django.db.models import get_model
from django.template import Library, Node, TemplateSyntaxError, Variable
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse

from ..models import Tag, TaggedItem
from ..utils import LINEAR, LOGARITHMIC


register = Library()

tag_ref_re = re.compile("(^|\s)#(\S+)")

class TagsForModelNode(Node):
    def __init__(self, model, context_var, counts):
        self.model = model
        self.context_var = context_var
        self.counts = counts

    def render(self, context):
        model = get_model(*self.model.split('.'))
        if model is None:
            raise TemplateSyntaxError(_('tags_for_model tag was given an invalid model: %s') % self.model)
        context[self.context_var] = Tag.objects.usage_for_model(model, counts=self.counts)
        return ''


class TagCloudForModelNode(Node):
    def __init__(self, model, context_var, **kwargs):
        self.model = model
        self.context_var = context_var
        self.kwargs = kwargs

    def render(self, context):
        model = get_model(*self.model.split('.'))
        if model is None:
{'fraction_non_alphanumeric': 0.10513036164844407, 'fraction_numerical': 0.0, 'mean_word_length': 3.3333333333333335, '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': '964071', 'n_tokens_mistral': 711, 'n_tokens_neox': 694, 'n_words': 191}