Return a list of genres found in text.
488505
def find(self, text):
        

        genres = []
        text = text.lower()

        category_counter = Counter()
        counter = Counter()

        for genre in self.db.genres:
            found = self.contains_entity(genre, text)
            if found:
                counter[genre] += found

                category = self.db.reference[genre]
                points = self.db.points[genre]
                points *= found

                # Add bonus points if additional terms points to category
                if category_counter[category] > 0:
                    points += 1

                category_counter[category] += points

        for tag in self.db.tags:
            found = self.contains_entity(tag, text)
            if found:
                category = self.db.reference[tag]

                if not counter[category]:
                    counter[category] += found

                points = self.db.points[tag]
                points *= found
                category_counter[category] += points

        if not category_counter:
            return genres

        main_category = category_counter.most_common(1)[0][0]

        # Convert counter to a flat list of genres, sorted by count
        sorted_genres = [ite for ite, it in counter.most_common()]

        for genre in sorted_genres:
            insert = True

            if self.unique_category:
                if not self.db.reference[genre] == main_category:
                    insert = False

            if insert:
                genres.append(genre)

        return genres
960614
def classify(self, text):
        
        score = self.score(text)
        if not score:
            return None
        return sorted(score.items(), key=lambda v: v[1])[-1][0]
847749
def check(text):
    """"""
    err = "glaad.terms"
    msg = "Possibly offensive term. Consider using '{}' instead of '{}'."

    list = [
        ["gay man",            ["homosexual man"]],
        ["gay men",            ["homosexual men"]],
        ["lesbian",            ["homosexual woman"]],
        ["lesbians",           ["homosexual women"]],
        ["gay people",         ["homosexual people"]],
        ["gay couple",         ["homosexual couple"]],
        ["sexual orientation", ["sexual preference"]],
        ["openly gay",         ["admitted homosexual", "avowed homosexual"]],
        ["equal rights",       ["special rights"]]
        ]

    return preferred_forms_check(text, list, err, msg, ignore_case=False)
841515
def filtered_entries(self):
        """"""
        return [
            e for e in self.entries if not any(fnmatch.fnmatch(e.name.lower(), p.lower()) for p in self.exclude_list)
        ]
371554
def findAllByBiSearch(self, strSeq) :
		""""""
		arr = self.encode(strSeq)
		lst = []
		self._dichFind(arr[0], self, 0, lst)
		return lst
273364
def parse_content(self, text):
        """"""
        raw_content = self.raw_content
        raw_content.clear()
        formal_collect = {}

        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            try:
                split = self.visible_empty_line_re.split(text)
            except ValueError:  # python >= 3.5
                split = [text]

        option_split_re = self.option_split_re
        name = re.compile(re.escape(self.option_name), re.IGNORECASE)
        for text in filter(lambda x: x and x.strip(), split):

            # logger.warning('get options group:\n%r', text)
            with warnings.catch_warnings():
                warnings.simplefilter("ignore")
                try:
                    split_options = option_split_re.split(text)
                except ValueError:  # python >= 3.5
                    continue

            split_options.pop(0)

            for title, section in zip(split_options[::2], split_options[1::2]):
                prefix, end = name.split(title)

                prefix = prefix.strip()

                section = section.rstrip()
                if end.endswith('\n'):
                    formal = section
                else:
                    formal = ' ' * len(title) + section

                formal_collect.setdefault(prefix, []).append(formal)

                # logger.error((title, section))
                if prefix in raw_content:
                    # TODO: better handling way?
                    if self.namedoptions:
                        log = logger.warning
                    else:
                        log = logger.debug
                    log('duplicated options section %s', prefix)

                    raw_content[prefix] += '\n%s%s' % (title, section)
                else:
                    raw_content[prefix] = title + section

        if formal_collect:
            for each_title, values in formal_collect.items():
                value = '\n'.join(map(textwrap.dedent, values))
                formal_collect[each_title] = value

        self.formal_content = formal_collect
770640
def _filter(self, text):
        """"""

        if self.urls:
            text = RE_LINK.sub('', text)
        if self.emails:
            text = RE_MAIL.sub('', text)
        return text
958198
def fuzzyfinder(text, collection):
    """"""
    suggestions = []
    if not isinstance(text, six.text_type):
        text = six.u(text)
    pat = '.*?'.join(map(re.escape, text))
    regex = re.compile(pat, flags=re.IGNORECASE)
    for item in collection:
        r = regex.search(item)
        if r:
            suggestions.append((len(r.group()), r.start(), item))

    return (z for _, _, z in sorted(suggestions))
565770
def extract_emails(text):
    """"""
    text = text.replace(u'\u2024', '.')
    emails = []
    for m in EMAIL_RE.findall(text):
        emails.append(m[0])
    return emails
42387
def natural_keys(text):
    '''
    
    '''
    return [int(c) if c.isdigit() else c for c in re.split(r'(\d+)', text)]
1247649
def search_fast(self, text):
    """"""

    resp = self.impl.get(
        "{base_url}/{text}/json".format(base_url=self.base_url, text=text)
    )
    return resp.json()["info"]["package_url"]
773224
def search_texts(args, parser):
    """"""
    store = utils.get_data_store(args)
    corpus = utils.get_corpus(args)
    catalogue = utils.get_catalogue(args)
    store.validate(corpus, catalogue)
    ngrams = []
    for ngram_file in args.ngrams:
        ngrams.extend(utils.get_ngrams(ngram_file))
    store.search(catalogue, ngrams, sys.stdout)
527052
def genres
      doc.xpath("//h4[contains(., 'Genre')]/..").search("a").map { |g|
        g.content.strip unless g.content =~ /See more/
      }.compact
    rescue
      nil
    end
468843
def genrepl(scope):
    """"""

    def repl(match):
        """Internal replacement function."""

        name = match.group('name')

        value = lookup(name, scope=scope)

        result = name.replace('.', '_')
        scope[result] = value

        return result

    return repl
174193
def find(self, sought, view='lemma'):
        '''
        
        '''
        hits = []
        for sentence in self._sentences:
            hits += sentence.find(sought, view)
        return hits
471819
def get_text_style(text):
    """"""
    style = {}
    style['alpha'] = text.get_alpha()
    if style['alpha'] is None:
        style['alpha'] = 1
    style['fontsize'] = text.get_size()
    style['color'] = color_to_hex(text.get_color())
    style['halign'] = text.get_horizontalalignment()  # left, center, right
    style['valign'] = text.get_verticalalignment()  # baseline, center, top
    style['malign'] = text._multialignment  # text alignment when '\n' in text
    style['rotation'] = text.get_rotation()
    style['zorder'] = text.get_zorder()
    return style
637896
def re_filter(text, regexps):
    """"""
    if not regexps:
        return text

    matched_text = []
    compiled_regexps = [re.compile(x) for x in regexps]
    for line in text:
        if line in matched_text:
            continue

        for regexp in compiled_regexps:
            found = regexp.search(line)
            if found and found.group():
                matched_text.append(line)

    return matched_text or text