Compute matches when text is a simple name.

        Return a list of all keywords, built-in functions and names currently
        defined in self.namespace that match.
331132
def global_matches(self, text):
        
        import keyword
        matches = []
        seen = {"__builtins__"}
        n = len(text)
        for word in keyword.kwlist:
            if word[:n] == text:
                seen.add(word)
                matches.append(word)
        for nspace in [self.namespace, builtins.__dict__]:
            for word, val in nspace.items():
                if word[:n] == text and word not in seen:
                    seen.add(word)
                    matches.append(self._callable_postfix(val, word))
        return matches
240894
def name_match_funcdef_handle(self, original, loc, tokens):
        """"""
        if len(tokens) == 2:
            func, matches = tokens
            cond = None
        elif len(tokens) == 3:
            func, matches, cond = tokens
        else:
            raise CoconutInternalException("invalid match function definition tokens", tokens)
        matcher = Matcher(loc, match_check_var)

        req_args, def_args, star_arg, kwd_args, dubstar_arg = split_args_list(matches, loc)
        matcher.match_function(match_to_args_var, match_to_kwargs_var, req_args + def_args, star_arg, kwd_args, dubstar_arg)

        if cond is not None:
            matcher.add_guard(cond)

        before_docstring = (
            "def " + func
            + "(*" + match_to_args_var + ", **" + match_to_kwargs_var + "):\n"
            + openindent
        )
        after_docstring = (
            match_check_var + " = False\n"
            + matcher.out()
            # we only include match_to_args_var here because match_to_kwargs_var is modified during matching
            + self.pattern_error(original, loc, match_to_args_var, match_check_var) + closeindent
        )
        return before_docstring, after_docstring
950915
def find_matches(self, list_title):
        
        list_title_matches = []
        # Generate every possible tuple of titles and safe the matched string in a list.
        for a, b, in itertools.combinations(list_title, 2):
            if a == b:
                list_title_matches.append(a)

        return list_title_matches
935997
def _get_standard_tc_matches(text, full_text, options):
    '''
    
    '''
    final_matches = [o for o in options if o.startswith(full_text)]
    return final_matches
325578
def query_names(self, pat):
        """"""

        for item in self.chnames.items():
            if fnmatch.fnmatchcase(item[1], pat):
                print item
252283
def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace:
        
        if pattern is None:
            raise ValueError('cannot have null pattern')

        namespace = self.get_namespace_by_keyword_pattern(keyword, pattern)

        if namespace is None:
            log.info('creating regex namespace: %s:%s', keyword, pattern)
            namespace = Namespace(
                keyword=keyword,
                pattern=pattern
            )
            self.session.add(namespace)
            self.session.commit()

        return namespace
1283095
def filter_wildcard(names, pattern):
    
    return tuple(name for name in names
                 if fnmatch.fnmatch(name, pattern))
192850
def matching_line(lines, keyword):
    
    for line in lines:
        matching = match(line,keyword)
        if matching != None:
            return matching
    return None
1123516
def has_regex_namespace_name(self, namespace: str, name: str) -> bool:
        """"""
        return self.has_regex_namespace(namespace) and self.namespace_to_pattern[namespace].match(name)
315276
def has_namespace_name(self, line: str, position: int, namespace: str, name: str) -> bool:
        """"""
        self.raise_for_missing_namespace(line, position, namespace, name)
        return self.has_enumerated_namespace_name(namespace, name) or self.has_regex_namespace_name(namespace, name)
849051
def findLastCharIndexMatching(text, func):
    
    for i in range(len(text) - 1, -1, -1):
      if func(text[i]):
        return i
46870
def namespace(self, name=None, function=None, recursive=None):
        

        return (
            self._find_single(
                scopedef.scopedef_t._impl_matchers[namespace_t.namespace],
                name=name,
                function=function,
                recursive=recursive)
        )
159324
def get_matches(self, text, cache=None, conflict_resolver=resolve_using_maximal_coverage):
        """"""
        is_root_node = False
        if cache is None:
            cache = {}
            is_root_node = True
        if id(self) in cache:
            return cache[id(self)]
        matches = self.get_matches_without_cache(text, cache=cache)
        cache[id(self)] = matches

        # if this is the root node, resolve the matches
        if is_root_node and conflict_resolver is not None:
            return conflict_resolver(matches)
        return matches
531369
def keywords(text):
    
    text = split_words(text)
    numWords = len(text)  # of words before removing blacklist words
    freq = Counter(x for x in text if x not in stopWords)

    minSize = min(10, len(freq))  # get first 10
    keywords = {x: y for x, y in freq.most_common(minSize)}  # recreate a dict

    for k in keywords:
        articleScore = keywords[k]*1.0 / numWords
        keywords[k] = articleScore * 1.5 + 1

    return keywords
1165677
def namespace_match(pattern: str, namespace: str):
    
    if pattern[0] == '*' and namespace.endswith(pattern[1:]):
        return True
    elif pattern == namespace:
        return True
    return False
1068780
def get_matches_lineno(code, fn_name):
    ""
    class Walker(ast.NodeVisitor):
        def __init__(self):
            self._hits = set()

        #pylint: disable=E0213,E1102    
        def onvisit(fn):
            def wrap(self, node):
                fn(self,node)
                super(Walker, self).generic_visit(node)
            return wrap
        
        @onvisit
        def visit_FunctionDef(self, node):
            if node.name == fn_name:
                self._hits.add(node)
            return node
        
        @property
        def hits(self):
            return list(sorted([n.lineno + 1 for n in self._hits]))
    
    walker = Walker()
    walker.visit(ast.parse(code))
    return walker.hits
41896
def tag(self, text):
        
        matches = self._match(text.text)
        matches = self._resolve_conflicts(matches)

        if self.return_layer:
            return matches
        else:
            text[self.layer_name] = matches