Tries to scrape the gender for a given noun from leo.org.
350625
def gender(self):
		'''  '''

		element = self._first('NN')
		if element:
			if re.search('([m|f|n)])\.', element, re.U):
				genus = re.findall('([m|f|n)])\.', element, re.U)[0]
				return genus
696886
def interested_in(self):
        
        genders = []

        for gender in self.cache['interested_in']:
            genders.append(gender)

        return genders
575424
async def get_gender(self) -> User.Gender:
        
        u = await self._get_user()

        try:
            return User.Gender(u.get('gender'))
        except ValueError:
            return User.Gender.unknown
537159
def full_name(self, gender: Optional[Gender] = None,
                  reverse: bool = False) -> str:
        
        if gender is None:
            gender = get_random_item(Gender, rnd=self.random)

        if gender and isinstance(gender, Gender):
            gender = gender
        else:
            raise NonEnumerableError(Gender)

        fmt = '{1} {0}' if reverse else '{0} {1}'
        return fmt.format(
            self.name(gender),
            self.surname(gender),
        )
1277746
def in_words(amount, gender=None):
    
    try:
        res = numeral.in_words(amount, getattr(numeral, str(gender), None))
    except Exception as err:
        # because filter must die silently
        res = default_value % {'error': err, 'value': str(amount)}
    return res
362724
function inflect(gender, name, gcase, nametype) {
        var nametype_rulesets = rules[nametype],
            parts = name.split('-'),
            result = [];
        for (var i = 0; i < parts.length; i++) {
            var part = parts[i], first_word = i === 0 && parts.size > 1,
                rule = find_rule_global(gender, part,
                    nametype_rulesets, {first_word: first_word});
            if (rule) result.push(apply_rule(part, gcase, rule));
            else result.push(part);
        }
        return result.join('-');
    }
953878
def extract_object_names_from_docs(filename):
    """"""
    text = split_code_and_text_blocks(filename)[1]
    text = '\n'.join(t[1] for t in text if t[0] == 'text')
    regex = re.compile(r':(?:'
                       r'func(?:tion)?|'
                       r'meth(?:od)?|'
                       r'attr(?:ibute)?|'
                       r'obj(?:ect)?|'
                       r'class):`(\S*)`'
                       )
    return [(x, x) for x in re.findall(regex, text)]
382373
def _language(self, item):
        """"""

        response = item['spider_response'].body
        root = html.fromstring(response)

        # Check for lang-attributes
        lang = root.get('lang')

        if lang is None:
            lang = root.get('xml:lang')

        # Check for general meta tags
        if lang is None:
            meta = root.cssselect('meta[name="language"]')
            if len(meta) > 0:
                lang = meta[0].get('content')

        # Check for open graph tags
        if lang is None:
            meta = root.cssselect('meta[property="og:locale"]')
            if len(meta) > 0:
                lang = meta[0].get('content')

        # Look for <article> elements and inspect the one with the largest payload with langdetect
        if lang is None:
            article_list = []
            for article in root.xpath('//article'):
                article_list.append(re.sub(r'\s+', ' ', article.text_content().strip()))
                if len(article_list) > 0:
                    lang = detect(max(article_list))

        # Analyze the whole body with langdetect
        if lang is None:
            try:
                lang = detect(root.text_content().strip())
            except LangDetectException:
                pass

        # Try to normalize output
        if lang is not None:
            # First search for suitable locale in the original output
            matches = self.langcode_pattern.search(lang)
            if matches is not None:
                lang = matches.group(0)
            else:
                # If no match was found, normalize the original output and search again
                normalized = locale.normalize(re.split(r'\s|;|,', lang.strip())[0])
                matches = self.langcode_pattern.search(normalized)
                if matches is not None:
                    lang = matches.group(0)

        return lang
60327
def iter_links_by_attrib(self, element):
        ''''''
        for attrib_name in element.attrib.keys():
            attrib_value = element.attrib.get(attrib_name)

            if attrib_name in self.LINK_ATTRIBUTES:
                if self.javascript_scraper and \
                        attrib_value.lstrip().startswith('javascript:'):
                    for link in self.iter_links_by_js_attrib(
                            attrib_name, percent_decode(attrib_value)):
                        yield link
                else:
                    yield attrib_name, attrib_value

            elif self.javascript_scraper and \
                    attrib_name[:5] in self.DYNAMIC_ATTRIBUTES:
                for link in self.iter_links_by_js_attrib(attrib_name,
                                                         attrib_value):
                    yield link

            elif attrib_name.startswith('data-'):
                if is_likely_link(attrib_value) \
                        and not is_unlikely_link(attrib_value):
                    yield attrib_name, attrib_value

            elif attrib_name == 'srcset':
                items = self.iter_links_by_srcset_attrib(
                    attrib_name, attrib_value)

                for item in items:
                    yield item
337229
def _filter_candidates(self, tokens, candidates):
        """"""
        results = []
        for abbr_span, long_span in candidates:
            abbr = tokens[abbr_span[0]:abbr_span[1]]
            long = tokens[long_span[0]:long_span[1]]
            if not all(a in long for a in abbr) and len(''.join(long)) > len(''.join(abbr)):
                results.append((abbr_span, long_span))
        return results
402195
function find_rule_global(gender, name, nametype_rulesets, features) {
        if (!features) features = {};
        var tags = [];
        for (var key in features) {
            if (features.hasOwnProperty(key)) tags.push(key);
        }
        if (nametype_rulesets.exceptions) {
            var rule = find_rule_local(
                gender, name, nametype_rulesets.exceptions, true, tags);
            if (rule) return rule;
        }
        return find_rule_local(
            gender, name, nametype_rulesets.suffixes, false, tags);
    }
312594
def get_attrib(self, et_node, prefixed_attrib):
        """"""
        prefix, attrib = prefixed_attrib.split(':')
        return et_node.get('{{{0}}}{1}'.format(self.namespaces[prefix],
                                               attrib))
1119029
def extract(self, item):
        

        article_candidate = ArticleCandidate()
        article_candidate.extractor = self._name()
        article_candidate.title = self._title(item)
        article_candidate.description = self._description(item)
        article_candidate.text = self._text(item)
        article_candidate.topimage = self._topimage(item)
        article_candidate.author = self._author(item)
        article_candidate.publish_date = self._publish_date(item)
        article_candidate.language = self._language(item)

        return article_candidate
395010
function tokenize(content, rules = parseOrder) {
    let data = []
    if(content) {
        let lines = content.split(/(\r\n|\n)/)
        for (let idx = 0; idx < lines.length; idx++) {
            for (let i = 0; i < lines[idx].length;) {
                let chunk = lines[idx].slice(i)
                let match = rules.some(item => {
                    if (item.pattern.test(chunk)) {
                        let matchObject = chunk.match(item.pattern)
                        i += matchObject[0].length
                        data.push([ item.label, matchObject[0] ])
                        return true
                    }
                })
                if (!match) {
                    data.push([ UNKNOWN, chunk[i] ])
                    i++
                }
            }
        }
    }
    return data
}
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)
1355921
public function getGender() {

    if (empty($this->firstName)) {
      throw new Exception('Property firstName cannot be empty');
    }

    if (!extension_loaded('Gender')) {
      throw new Exception('PHP extension Gender is not loaded');
    }

    $this->firstName = mb_convert_case($this->firstName, MB_CASE_LOWER, "UTF-8");
    $this->lastName  = mb_convert_case($this->lastName,  MB_CASE_LOWER, "UTF-8");

    $this->country   = strtolower($this->country);

    $alias = array(
      'gb' => 1,
      'ie' => 2,
      'us' => 3,
      'es' => 4,
      'pt' => 5,
      'it' => 6,
      'mt' => 7,
      'fr' => 8,
      'be' => 9,
      'lu' => 10,
      'nl' => 11,
      'de' => 12,
      'at' => 14,
      'ch' => 15,
      'is' => 16,
      'dk' => 17,
      'no' => 18,
      'se' => 19,
      'fi' => 20,
      'ee' => 21,
      'lv' => 22,
      'lt' => 23,
      'pl' => 24,
      'cz' => 25,
      'sk' => 26,
      'hu' => 27,
      'ro' => 28,
      'bg' => 29,
      'ba' => 30,
      'hr' => 31,
      'mk' => 33,
      'me' => 34,
      'rs' => 35,
      'si' => 36,
      'al' => 37,
      'gr' => 38,
      'ru' => 39,
      'by' => 40,
      'md' => 41,
      'ua' => 42,
      'am' => 43,
      'az' => 44,
      'ge' => 45,
      'kz' => 46,
      'uz' => 46,
      'tr' => 47,
      'sa' => 48,
      'il' => 49,
      'cn' => 50,
      'in' => 51,
      'jp' => 52,
      'kr' => 53,
    );

    if (array_key_exists($this->country, $alias)) {
      $countryNum = $alias[$this->country];
    }
    else {
      $countryNum = 0;
    }

    $genObj = new Gender;
    $result = $genObj->get($this->firstName, $countryNum);

    switch ($result) {
      case Gender::IS_FEMALE:
        return 'F';
      case Gender::IS_MOSTLY_FEMALE:
        return 'F';
      case Gender::IS_MALE:
        return 'M';
      case Gender::IS_MOSTLY_MALE:
        return 'M';
    }

    #############################################################

    if (preg_match('/\S+á$/', $this->lastName)) {
      return 'F';
    }

    # Borrowed from <https://github.com/petewarden>
    if (preg_match('/^joh?n/', $this->firstName)) return 'M';
    if (preg_match('/^th?o(m|b)/', $this->firstName)) return 'M';
    if (preg_match('/^frank/', $this->firstName)) return 'M';
    if (preg_match('/^bil/', $this->firstName)) return 'M';
    if (preg_match('/^hans/', $this->firstName)) return 'M';
    if (preg_match('/^ron/', $this->firstName)) return 'M';
    if (preg_match('/^ro(z|s)/', $this->firstName)) return 'F';
    if (preg_match('/^walt/', $this->firstName)) return 'M';
    if (preg_match('/^krishna/', $this->firstName)) return 'M';
    if (preg_match('/^tri(c|sh)/', $this->firstName)) return 'F';
    if (preg_match('/^pas(c|qu)al$/', $this->firstName)) return 'M';
    if (preg_match('/^ellie/', $this->firstName)) return 'F';
    if (preg_match('/^anfernee/', $this->firstName)) return 'M';
    # most names ending in a/e/i/y are female
    if (preg_match('/^.*[aeiy]$/', $this->firstName)) return 'F';
    # allison and variations
    if (preg_match('/^all?[iy]((ss?)|z)on$/', $this->firstName)) return 'F';
    # cathleen, eileen, maureen
    if (preg_match('/een$/', $this->firstName)) return 'F';
    # barry, larry, perry
    if (preg_match('/^[^s].*r[rv]e?y?$/', $this->firstName)) return 'M';
    # clive, dave, steve
    if (preg_match('/^[^g].*v[ei]$/', $this->firstName)) return 'M';
    # carolyn, gwendolyn, vivian
    if (preg_match('/^[^bd].*(b[iy]|y|via)nn?$/', $this->firstName)) return 'F';
    # dewey, stanley, wesley
    if (preg_match('/^[^ajklmnp][^o][^eit]*([glrsw]ey|lie)$/', $this->firstName)) return 'M';
    # heather, ruth, velvet
    if (preg_match('/^[^gksw].*(th|lv)(e[rt])?$/', $this->firstName)) return 'F';
    # gregory, jeremy, zachary
    if (preg_match('/^[cgjwz][^o][^dnt]*y$/', $this->firstName)) return 'M';
    # leroy, murray, roy
    if (preg_match('/^.*[rlr][abo]y$/', $this->firstName)) return 'M';
    # abigail, jill, lillian
    if (preg_match('/^[aehjl].*il.*$/', $this->firstName)) return 'F';
    # duane, eugene, rene
    if (preg_match('/^.*[grguw][ae]y?ne$/', $this->firstName)) return 'M';
    # fleur, lauren, muriel
    if (preg_match('/^[flm].*ur(.*[^eotuy])?$/', $this->firstName)) return 'F';
    # lance, quincy, vince
    if (preg_match('/^[clmqtv].*[^dl][in]c.*[ey]$/', $this->firstName)) return 'M';
    # margaret, marylou, miri;
    if (preg_match('/^m[aei]r[^tv].*([^cklnos]|([^o]n))$/', $this->firstName)) return 'F';
    # clyde, kyle, pascale
    if (preg_match('/^.*[ay][dl]e$/', $this->firstName)) return 'M';
    # blake, luke, mi;
    if (preg_match('/^[^o]*ke$/', $this->firstName)) return 'M';
    # carol, karen, shar;
    if (preg_match('/^[cks]h?(ar[^lst]|ry).+$/', $this->firstName)) return 'F';
    # pam, pearl, rachel
    if (preg_match('/^[pr]e?a([^dfju]|qu)*[lm]$/', $this->firstName)) return 'F';
    # annacarol, leann, ruthann
    if (preg_match('/^.*[aa]nn.*$/', $this->firstName)) return 'F';
    # deborah, leah, sarah
    if (preg_match('/^.*[^cio]ag?h$/', $this->firstName)) return 'F';
    # frances, megan, susan
    if (preg_match('/^[^ek].*[grsz]h?an(ces)?$/', $this->firstName)) return 'F';
    # ethel, helen, gretchen
    if (preg_match('/^[^p]*([hh]e|[ee][lt])[^s]*[ey].*[^t]$/', $this->firstName)) return 'F';
    # george, joshua, theodore
    if (preg_match('/^[^el].*o(rg?|sh?)?(e|ua)$/', $this->firstName)) return 'M';
    # delores, doris, precious
    if (preg_match('/^[dp][eo]?[lr].*s$/', $this->firstName)) return 'F';
    # anthony, henry, rodney
    if (preg_match('/^[^jpswz].*[denor]n.*y$/', $this->firstName)) return 'M';
    # karin, kim, kristin
    if (preg_match('/^k[^v]*i.*[mns]$/', $this->firstName)) return 'F';
    # bradley, brady, bruce
    if (preg_match('/^br[aou][cd].*[ey]$/', $this->firstName)) return 'M';
    # agnes, alexis, glynis
    if (preg_match('/^[acgk].*[deinx][^aor]s$/', $this->firstName)) return 'F';
    # ignace, lee, wallace
    if (preg_match('/^[ilw][aeg][^ir]*e$/', $this->firstName)) return 'M';
    # juliet, mildred, millicent
    if (preg_match('/^[^agw][iu][gl].*[drt]$/', $this->firstName)) return 'F';
    # ari, bela, ira
    if (preg_match('/^[abeiuy][euz]?[blr][aeiy]$/', $this->firstName)) return 'M';
    # iris, lois, phyllis
    if (preg_match('/^[egilp][^eu]*i[ds]$/', $this->firstName)) return 'F';
    # randy, timothy, tony
    if (preg_match('/^[art][^r]*[dhn]e?y$/', $this->firstName)) return 'M';
    # beatriz, bridget, harriet
    if (preg_match('/^[bhl].*i.*[rtxz]$/', $this->firstName)) return 'F';
    # antoine, jerome, tyrone
    if (preg_match('/^.*oi?[mn]e$/', $this->firstName)) return 'M';
    # danny, demetri, dondi
    if (preg_match('/^d.*[mnw].*[iy]$/', $this->firstName)) return 'M';
    # pete, serge, shane
    if (preg_match('/^[^bg](e[rst]|ha)[^il]*e$/', $this->firstName)) return 'M';
    # angel, gail, isabel
    if (preg_match('/^[adfgim][^r]*([bg]e[lr]|il|wn)$/', $this->firstName)) return 'F';
    #------------------------------
    if (in_array($this->firstName, $this->male)) return 'M';
    #------------------------------
    if (in_array($this->firstName, $this->female)) return 'F';
    #---- End of borrowed code ----
    return 'N';
  }
854192
def filter_vcf_by_sex(vcf_file, items):
    
    out_file = "%s-ploidyfix%s" % utils.splitext_plus(vcf_file)
    if not utils.file_exists(out_file):
        genders = list(_configured_genders(items))
        is_female = len(genders) == 1 and genders[0] and genders[0] in ["female", "f"]
        if is_female:
            orig_out_file = out_file
            out_file = orig_out_file.replace(".vcf.gz", ".vcf")
            with file_transaction(items[0], out_file) as tx_out_file:
                with open(tx_out_file, "w") as out_handle:
                    with utils.open_gzipsafe(vcf_file) as in_handle:
                        for line in in_handle:
                            if line.startswith("#"):
                                out_handle.write(line)
                            else:
                                chrom = chromosome_special_cases(line.split("\t"))
                                if chrom != "Y":
                                    out_handle.write(line)
            if orig_out_file.endswith(".gz"):
                out_file = vcfutils.bgzip_and_index(out_file, items[0]["config"])
        else:
            out_file = vcf_file
    return out_file