Try to match the TextLayer with choice's intents.
199345
async def _rank_text(self, choices):
        

        tl = self.request.get_layer(l.RawText)
        best = 0.0

        for slug, params in choices.items():
            strings = []

            if params['intent']:
                intent = getattr(intents, params['intent'])
                strings += await intent.strings(self.request)

            if params['text']:
                strings.append((params['text'],))

            matcher = Matcher([tuple(Trigram(y) for y in x) for x in strings])
            score = matcher % Trigram(await render(tl.text, self.request))

            if score > best:
                self.chosen = params
                self.slug = slug
                best = score

        if self.when is None or self.slug == self.when:
            return best
256763
def has_match_at_current_position(self, sub):
        
        return self.text.find(sub, self.cursor_position) == self.cursor_position
842870
function searchPath(newValue) {
            if (!newValue || newValue.length < 2) {
                return undefined;
            }

            var regexp = new RegExp(LxUtils.escapeRegexp(newValue), 'ig');

            return _searchPath(lxSelect.choices, regexp);
        }
690463
def match_subselectors(self, el, selectors):
        """"""

        match = True
        for sel in selectors:
            if not self.match_selectors(el, sel):
                match = False
        return match
1039846
def _tryMatch(self, textToMatchObject):
        
        # Special case. if pattern starts with \b, we have to check it manually,
        # because string is passed to .match(..) without beginning
        if self.wordStart and \
           (not textToMatchObject.isWordStart):
                return None

        #Special case. If pattern starts with ^ - check column number manually
        if self.lineStart and \
           textToMatchObject.currentColumnIndex > 0:
            return None

        if self.dynamic:
            string = self._makeDynamicSubsctitutions(self.string, textToMatchObject.contextData)
            regExp = self._compileRegExp(string, self.insensitive, self.minimal)
        else:
            regExp = self.regExp

        if regExp is None:
            return None

        wholeMatch, groups = self._matchPattern(regExp, textToMatchObject.text)
        if wholeMatch is not None:
            count = len(wholeMatch)
            return RuleTryMatchResult(self, count, groups)
        else:
            return None
597784
boolean matchText(
            final boolean blockMatching,
            final int markupLevel, final int markupBlockIndex) {

        checkMarkupLevel(markupLevel);

        if (this.markupSelectorItem.anyLevel() || markupLevel == 0 || (this.prev != null && this.prev.matchedMarkupLevels[markupLevel - 1])) {
            // This text has not matched yet, but might match, so we should check

            this.matchesThisLevel = this.markupSelectorItem.matchesText(markupBlockIndex, this.markupBlockMatchingCounter);

            if (matchesPreviousOrCurrentLevel(markupLevel)) {
                // This filter was already matched by a previous level (through an "open" event), so just delegate to next.

                if (this.next != null) {
                    return this.next.matchText(blockMatching, markupLevel, markupBlockIndex);
                }
                return (blockMatching? true : this.matchesThisLevel);

            } else if (this.matchesThisLevel) {
                // This filter was not matched before. So the fact that it matches now means we need to consume it,
                // therefore not delegating.

                return (this.next == null);

            }

        } else if (matchesPreviousOrCurrentLevel(markupLevel)) {
            // This filter was already matched by a previous level (through an "open" event), so just delegate to next.

            if (this.next != null) {
                return this.next.matchText(blockMatching, markupLevel, markupBlockIndex);
            }
            return blockMatching;

        }

        return false;

    }
4404
def match(self, item):
        
        val = getattr(item, self._name)
        if val is not None:
            for fileinfo in val:
                if fnmatch.fnmatchcase(fileinfo.path.lower(), self._value):
                    return True
            return False
1253206
def _match_dialog(self, query, dialogues=None):
        
        if dialogues is None:
            dialogues = self._dialogues

        # Try to match in the queries
        if query in dialogues:
            response = dialogues[query]
            logger.debug('Found response in queries: %s' % repr(response))

            return response
403351
def match(tgt, opts=None):
    '''
    
    '''
    if not opts:
        return bool(re.match(tgt, __opts__['id']))
    else:
        return bool(re.match(tgt, opts['id']))
1248982
def matches(self, filter_props):
        """"""
        if filter_props is None:
            return False

        found_one = False
        for key, value in filter_props.items():
            if key in self.properties and value != self.properties[key]:
                return False
            elif key in self.properties and value == self.properties[key]:
                found_one = True

        return found_one
188935
def match(tgt, opts=None):
    '''
    
    '''
    if not opts:
        opts = __opts__
    if not isinstance(tgt, six.string_types):
        return False

    return fnmatch.fnmatch(opts['id'], tgt)
963658
function matchedText(pattern, candidate) {
        ts.Debug.assert(isPatternMatch(pattern, candidate));
        return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length);
    }
647498
def match_var(self, tokens, item):
        """"""
        setvar, = tokens
        if setvar != wildcard:
            if setvar in self.names:
                self.add_check(self.names[setvar] + " == " + item)
            else:
                self.add_def(setvar + " = " + item)
                self.names[setvar] = item
1169002
function (suggestions, textEntry) {
                var matchValueIndex = -1, suggestion;
                for (var index = 0, len = suggestions.length, label, ariaLabel; index < len; index += 1) {
                    suggestion = suggestions[index];
                    // if it's the first exact match, store it
                    if (matchValueIndex == -1) {
                        if (suggestion.exactMatch) {
                            matchValueIndex = index;
                        }
                    }
                    label = this._getLabelFromSuggestion(suggestion);
                    ariaLabel = this.waiSuggestionAriaLabelGetter ? this.waiSuggestionAriaLabelGetter({
                        value: suggestion,
                        index: index,
                        total: len
                    }) : null;
                    var tmp = {
                        entry : textEntry,
                        label : label,
                        ariaLabel : ariaLabel,
                        value : suggestion
                    };
                    suggestions[index] = tmp;
                }
                return this.preselect === "none" ? -1 : matchValueIndex;
            }
1113006
function findTextStyle(item, queue)
{
    if (item instanceof TextStyle)
    {
        if (queue.indexOf(item) === -1)
        {
            queue.push(item);
        }

        return true;
    }

    return false;
}
194459
def choice(opts, default=1, text='Please make a choice.'):
    
    opts_len = len(opts)
    opts_enum = enumerate(opts, 1)
    opts = list(opts)

    for key, opt in opts_enum:
        click.echo('[{k}] {o}'.format(k=key, o=opt[1] if isinstance(opt, tuple) else opt))

    click.echo('-' * 12)
    opt = click.prompt(text, default, type=click.IntRange(1, opts_len))
    opt = opts[opt - 1]
    return opt[0] if isinstance(opt, tuple) else opt
593964
def overlaps_with(self, othermatch, strict=False):
        '''
        
        '''
        one = self.matches_entry(othermatch, strict)
        if strict:
            return one
        return one and othermatch.matches_entry(self, strict)