<commit_before>from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User


class BaseModel(models.Model):
    """Abstract model with bucketlist and items information"""
    name = models.CharField(blank=False, unique=True, max_length=255)
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now_add=True)

    class Meta:
        abstract = True


class Bucketlist(BaseModel):<commit_msg>(feature) Add search capability to API<commit_after>from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
import re


def normalize(query_string):
    """Return a tuple of words from a query statement"""
    terms = re.compile(r'"([^"]+)"|(\S+)').findall(query_string)
    normspace = re.compile(r'\s{2,}').sub
    return (normspace(' ', (t[0] or t[1]).strip()) for t in terms)


class BaseModel(models.Model):
    """Abstract model with bucketlist and items information"""
    name = models.CharField(blank=False, unique=True, max_length=255)
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now_add=True)

    class Meta:
        abstract = True

    @classmethod
    def search(cls, query_string):
        """Searches the model table for words with the query string"""
        query_terms = normalize(query_string)
        for word in query_terms:
            query_object = models.Q(**{"name__icontains": word})
            return cls.objects.filter(query_object).order_by('date_created')


class Bucketlist(BaseModel):
{'fraction_non_alphanumeric': 0.10893512851897184, 'fraction_numerical': 0.0055079559363525096, 'mean_word_length': 4.3431372549019605, 'pattern_counts': {'":': 1, '<': 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': '2201039', 'n_tokens_mistral': 491, 'n_tokens_neox': 470, 'n_words': 125}