<commit_before>from deform import Form
from ekklesia_portal.helper.utils import cached_property
from ekklesia_portal.database.datamodel import Proposition, Tag
from ekklesia_portal.schema import PropositionSchema
from ekklesia_portal.forms import PropositionForm
from sqlalchemy_searchable import search


class Propositions:
    def __init__(self, mode=None, search=None, tag=None):
        self.search = search
        self.mode = mode
        self.tag = tag

    def propositions(self, q):
        propositions = q(Proposition)

        if self.search:
            propositions = search(propositions, self.search)

        if self.tag:<commit_msg>sort propositions search results by relevance<commit_after>from deform import Form
from ekklesia_portal.helper.utils import cached_property
from ekklesia_portal.database.datamodel import Proposition, Tag
from ekklesia_portal.schema import PropositionSchema
from ekklesia_portal.forms import PropositionForm
from sqlalchemy_searchable import search


class Propositions:
    def __init__(self, mode=None, search=None, tag=None):
        self.search = search
        self.mode = mode
        self.tag = tag

    def propositions(self, q):
        propositions = q(Proposition)

        if self.search:
            propositions = search(propositions, self.search, sort=True)

        if self.tag:
{'fraction_non_alphanumeric': 0.06403574087862993, 'fraction_numerical': 0.0, 'mean_word_length': 3.7157894736842105, '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': '4816018', 'n_tokens_mistral': 384, 'n_tokens_neox': 367, 'n_words': 105}