<commit_before># -*- coding: utf-8 -*-


class Matcher(object):

    def __init__(self,nvim):
        pass

    def process(self,name,ctx,startcol,matches):

        base = ctx['typed'][startcol-1:]

        matches = [m for m in matches if self._match(base,m)]

        # in python, 'A' sort's before 'a', we need to swapcase for the 'a'
        # sorting before 'A'
        matches.sort(key=lambda e: e['word'].swapcase())

        return matches


    def _match(self,base,item):
        if len(base)>len(item['word']):
            return False
        for a,b in zip(base,item['word']):
            if a.isupper() :
                if a!=b:
                    return False
            elif a!=b.lower():
                return False
        return True

<commit_msg>configurable case<commit_after># -*- coding: utf-8 -*-


class Matcher(object):

    def __init__(self,nvim):
        ignorecase,sartcase = nvim.eval('[&ignorecase,&smartcase]')
        if ignorecase:
            if smartcase:
                self._match = self._match_smart_case
            else:
                self._match = self._match_icase
        else:
            self._match = self._match_case

    def process(self,name,ctx,startcol,matches):

        base = ctx['typed'][startcol-1:]

        matches = [m for m in matches if self._match(base,m)]

        # in python, 'A' sort's before 'a', we need to swapcase for the 'a'
        # sorting before 'A'
        matches.sort(key=lambda e: e['word'].swapcase())

        return matches

    def _match_smart_case(self,base,item):
        if len(base)>len(item['word']):
            return False
        for a,b in zip(base,item['word']):
            if a.isupper() :
                if a!=b:
                    return False
            elif a!=b.lower():
                return False
        return True

    def _match_case(self,base,item):
        return base == item['word'][0:len(base)]

    def _match_icase(self,base,item):
        return base.lower() == item['word'][0:len(base)].lower()


{'fraction_non_alphanumeric': 0.13369511593487912, 'fraction_numerical': 0.0029600394671928957, 'mean_word_length': 1.9264069264069263, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7471061', 'n_tokens_mistral': 635, 'n_tokens_neox': 603, 'n_words': 150}