Extract author names out of refextract authors output.
328845
def _split_refextract_authors_str(authors_str):
    """"""
    author_seq = (x.strip() for x in RE_SPLIT_AUTH.split(authors_str) if x)
    res = []

    current = ''
    for author in author_seq:
        if not isinstance(author, six.text_type):
            author = six.text_type(author.decode('utf8', 'ignore'))

        # First clean the token.
        author = re.sub(r'\(|\)', '', author, re.U)
        # Names usually start with characters.
        author = re.sub(r'^[\W\d]+', '', author, re.U)
        # Names should end with characters or dot.
        author = re.sub(r'[^.\w]+$', '', author, re.U)

        # If we have initials join them with the previous token.
        if RE_INITIALS_ONLY.match(author):
            current += ', ' + author.strip().replace('. ', '.')
        else:
            if current:
                res.append(current)
            current = author

    # Add last element.
    if current:
        res.append(current)

    # Manual filterings that we don't want to add in regular expressions since
    # it would make them more complex.
    #  * ed might sneak in
    #  * many legacy refs look like 'X. and Somebody E.'
    #  * might miss lowercase initials
    filters = [
        lambda a: a == 'ed',
        lambda a: a.startswith(','),
        lambda a: len(a) == 1
    ]
    res = [r for r in res if all(not f(r) for f in filters)]
    return res
347225
private Extractors getExtractorsForMapName(String mapNameOrNull) {
        if (mapNameOrNull == null) {
            return Extractors.newBuilder(serializationService)
                    .build();
        }
        return mapServiceContext.getExtractors(mapNameOrNull);
    }
6845
function splitAuthor(author) {
	return author
		.split(/\s*[,\.\s]\s*/)
		.filter(function(i) { return !!i }) // Strip out blanks
		.filter(function(i) { return !/^[0-9]+(st|nd|rd|th)$/.test(i) }); // Strip out decendent numerics (e.g. '1st', '23rd')
}
1173632
def all_contributors(soup, detail="brief"):
    ""
    contrib_tags = raw_parser.contributors(soup)
    contributors = format_authors(soup, contrib_tags, detail)
    return contributors
654960
def _clean_rec_name(rec):
    
    out_id = []
    for char in list(rec.id):
        if char in ALLOWED_CONTIG_NAME_CHARS:
            out_id.append(char)
        else:
            out_id.append("_")
    rec.id = "".join(out_id)
    rec.description = ""
    return rec
347868
def fix_reference_name(name, blacklist=None):
    """"""
    name = "".join(re.split(r'[^0-9a-zA-Z_]', name))
    while name and not re.match(r'([a-zA-Z]+[0-9a-zA-Z_]*)$', name):
        if not re.match(r'[a-zA-Z]', name[0]):
            name = name[1:]
            continue
    name = str(name)
    if not name:
        name = "data"
    if blacklist is not None and name in blacklist:
        get_new_name = lambda index: name+('%03d' % index)
        index = 0
        while get_new_name(index) in blacklist:
            index += 1
        name = get_new_name(index)
    return name
703628
def cut_references(text_lines):
    """"""
    ref_sect_start = find_reference_section(text_lines)
    if ref_sect_start is not None:
        start = ref_sect_start["start_line"]
        end = find_end_of_reference_section(text_lines, start,
                                            ref_sect_start["marker"],
                                            ref_sect_start["marker_pattern"])
        del text_lines[start:end + 1]
    else:
        current_app.logger.warning("Found no references to remove.")
        return text_lines

    return text_lines
1255773
def reference_creator_surnames(self, index):
        """"""
        # TODO Not true, ex: ISBN 978-1-4398-3778-8. Return all creator types?
        # Academic books published as a collection of chapters contributed by
        # different authors have editors but not authors at the level of the
        # book (as opposed to the level of a chapter).
        creators = self.reference_data(index)["creators"]
        creator_types = [x["creatorType"] for x in creators]
        # 'name' (not split) might be used instead of 'firstName' and 'lastName'.
        try:
            if "author" in creator_types:
                return [x["lastName"] for x in creators if x["creatorType"] == "author"]
            else:
                return [x["lastName"] for x in creators]
        except KeyError:
            return []
522387
def authors(self):
        '''
            
        '''
        qs = self._valid_submissions().values_list('authors',flat=True).distinct()
        return qs
933843
public static Set<QualifiedName> extractNames(Expression expression, Set<NodeRef<Expression>> columnReferences)
    {
        ImmutableSet.Builder<QualifiedName> builder = ImmutableSet.builder();
        new QualifiedNameBuilderVisitor(columnReferences).process(expression, builder);
        return builder.build();
    }
733875
def get_one_author(author)
      return { "literal" => "" } if author.strip.blank?

      author = cleanup_author(author)
      names = Namae.parse(author)

      if names.blank? || is_personal_name?(author).blank?
        { "literal" => author }
      else
        name = names.first

        { "family" => name.family,
          "given" => name.given }.compact
      end
    end
25753
def set_authors(data):
    
    if "authors" in data:
        return

    shfile = os.path.join(os.path.dirname(__file__), "get_committers.sh")

    p = subprocess.Popen(["bash", shfile], stdout=subprocess.PIPE)
    out, _ = p.communicate()
    if p.returncode:
        return

    authors = out.strip().split('\n')
    authors = [x.strip() for x in authors]

    data["authors"] = authors
496158
function unParsePeople (data) {
  if (data.author) data.author = unParsePerson(data.author)
  ;["maintainers", "contributors"].forEach(function (set) {
    if (!Array.isArray(data[set])) return;
    data[set] = data[set].map(unParsePerson)
  })
  return data
}
1352283
def get_authors(filepath: str) -> List[str]:
    """"""
    str_oneline = r'(^__author__ = )(\[.*?\])'  # type" str
    comp_oneline = re.compile(str_oneline, re.MULTILINE)  # type: Pattern[str]
    with open(filepath) as file_open:
        file_read = file_open.read()  # type: str
    match = comp_oneline.findall(file_read)
    if match:
        inner_list_as_str = match[0][1]  # type: str
        inner_list = eval_str_to_list(inner_list_as_str)  # type: List[str]
        return inner_list
    return list()
521280
def reference_creators_citation(self, ref_id):
        """"""
        # FIXME Delayed refactoring. Use an index instead of an ID.
        index = self.reference_index(ref_id)
        creators = self.reference_creator_surnames(index)
        creator_count = len(creators)
        if creator_count == 0:
            return ""
        year = self.reference_year(index)
        if creator_count == 1:
            return "{} ({})".format(creators[0], year)
        elif creator_count == 2:
            return "{} and {} ({})".format(creators[0], creators[1], year)
        else:
            return "{} et al. ({})".format(creators[0], year)
750724
def identify_and_tag_authors(line, authors_kb):
    
    re_auth, re_auth_near_miss = get_author_regexps()

    # Replace authors which do not convert well from utf-8
    for pattern, repl in authors_kb:
        line = line.replace(pattern, repl)

    output_line = line

    # We matched authors here
    line = strip_tags(output_line)
    matched_authors = list(re_auth.finditer(line))
    # We try to have better results by unidecoding
    unidecoded_line = strip_tags(unidecode(output_line))
    matched_authors_unidecode = list(re_auth.finditer(unidecoded_line))

    if len(matched_authors_unidecode) > len(matched_authors):
        output_line = unidecode(output_line)
        matched_authors = matched_authors_unidecode

    # If there is at least one matched author group
    if matched_authors:
        matched_positions = []
        preceeding_text_string = line
        preceeding_text_start = 0
        for auth_no, match in enumerate(matched_authors):
            # Only if there are no underscores or closing arrows found in the matched author group
            # This must be checked for here, as it cannot be applied to the re without clashing with
            # other Unicode characters
            if line[match.start():match.end()].find("_") == -1:
                # Has the group with name 'et' (for 'et al') been found in the pattern?
                # Has the group with name 'es' (for ed. before the author) been found in the pattern?
                # Has the group with name 'ee' (for ed. after the author) been
                # found in the pattern?
                matched_positions.append({
                    'start': match.start(),
                    'end': match.end(),
                    'etal': match.group('et') or match.group('et2'),
                    'ed_start': match.group('es'),
                    'ed_end': match.group('ee'),
                    'multi_auth': match.group('multi_auth'),
                    'multi_surs': match.group('multi_surs'),
                    'text_before': preceeding_text_string[preceeding_text_start:match.start()],
                    'auth_no': auth_no,
                    'author_names': match.group('author_names')
                })
                # Save the end of the match, from where to snip the misc text
                # found before an author match
                preceeding_text_start = match.end()

        # Work backwards to avoid index problems when adding AUTH tags
        matched_positions.reverse()
        for m in matched_positions:
            dump_in_misc = False
            start = m['start']
            end = m['end']

            # Check the text before the current match to see if it has a bad
            # 'et al'
            lower_text_before = m['text_before'].strip().lower()
            for e in etal_matches:
                if lower_text_before.endswith(e):
                    # If so, this author match is likely to be a bad match on a
                    # missed title
                    dump_in_misc = True
                    break

            # An AND found here likely indicates a missed author before this text
            # Thus, triggers weaker author searching, within the previous misc text
            # (Check the text before the current match to see if it has a bad 'and')
            # A bad 'and' will only be denoted as such if there exists only one author after it
            # and the author group is legit (not to be dumped in misc)
            if not dump_in_misc and not (m['multi_auth'] or m['multi_surs']) \
                    and (lower_text_before.endswith(' and')):
                # Search using a weaker author pattern to try and find the
                # missed author(s) (cut away the end 'and')
                weaker_match = re_auth_near_miss.match(m['text_before'])
                if weaker_match and not (weaker_match.group('es') or weaker_match.group('ee')):
                    # Change the start of the author group to include this new
                    # author group
                    start = start - \
                        (len(m['text_before']) - weaker_match.start())
                # Still no match, do not add tags for this author match.. dump
                # it into misc
                else:
                    dump_in_misc = True

            add_to_misc = ""
            # If a semi-colon was found at the end of this author group, keep it in misc
            # so that it can be looked at for splitting heurisitics
            if len(output_line) > m['end']:
                if output_line[m['end']].strip(" ,.") == ';':
                    add_to_misc = ';'

            # Standardize eds. notation
            tmp_output_line = re.sub(re_ed_notation, '(ed.)',
                                     output_line[start:end], re.IGNORECASE)
            # Standardize et al. notation
            tmp_output_line = re.sub(re_etal, 'et al.',
                                     tmp_output_line, re.IGNORECASE)
            # Strip
            tmp_output_line = tmp_output_line.lstrip('.').strip(",:;- [](")
            if not tmp_output_line.endswith('(ed.)'):
                tmp_output_line = tmp_output_line.strip(')')

            # ONLY wrap author data with tags IF there is no evidence that it is an
            # ed. author. (i.e. The author is not referred to as an editor)
            # Does this author group string have 'et al.'?
            if m['etal'] and not (m['ed_start'] or m['ed_end'] or dump_in_misc):
                output_line = output_line[:start] \
                    + "<cds.AUTHetal>" \
                    + tmp_output_line \
                    + CFG_REFEXTRACT_MARKER_CLOSING_AUTHOR_ETAL \
                    + add_to_misc \
                    + output_line[end:]
            elif not (m['ed_start'] or m['ed_end'] or dump_in_misc):
                # Insert the std (standard) tag
                output_line = output_line[:start] \
                    + "<cds.AUTHstnd>" \
                    + tmp_output_line \
                    + CFG_REFEXTRACT_MARKER_CLOSING_AUTHOR_STND \
                    + add_to_misc \
                    + output_line[end:]
            # Apply the 'include in $h' method to author groups marked as
            # editors
            elif m['ed_start'] or m['ed_end']:
                ed_notation = " (eds.)"
                # Standardize et al. notation
                tmp_output_line = re.sub(re_etal, 'et al.',
                                         m['author_names'], re.IGNORECASE)
                # remove any characters which denote this author group
                # to be editors, just take the
                # author names, and append '(ed.)'
                output_line = output_line[:start] \
                    + "<cds.AUTHincl>" \
                    + tmp_output_line.strip(",:;- [](") \
                    + ed_notation \
                    + CFG_REFEXTRACT_MARKER_CLOSING_AUTHOR_INCL \
                    + add_to_misc \
                    + output_line[end:]

    return output_line
1303829
def _process_refs(x, labels):
    """"""

    # Scan the element list x for Cite elements with known labels
    for i, v in enumerate(x):
        if v['t'] == 'Cite' and len(v['c']) == 2 and \
          _get_label(v['t'], v['c']) in labels:

            # A new reference was found; create some empty attributes for it
            attrs = ['', [], []]

            # Extract the modifiers.  'attrs' is updated in place.  Element
            # deletion could change the index of the Cite being processed.
            if i > 0:
                i = _extract_modifier(x, i, attrs)

            # Attach the attributes
            v['c'].insert(0, attrs)

            # Remove surrounding brackets
            if i > 0 and i < len(x)-1:
                _remove_brackets(x, i)

            # The element list may be changed
            return None  # Forces processing to repeat via _repeat decorator

    return True