compile a map of author collab to group-author-key
344863
def collab_to_group_author_key_map(authors):
    """"""
    collab_map = {}
    for author in authors:
        if author.get("collab"):
            collab_map[author.get("collab")] = author.get("group-author-key")
    return collab_map
191363
function mapItem (item) {
  const title = item.pagemap.metatags[0]['og:title'] ||
                item.pagemap.metatags[0]['dc.title'] ||
                item.title

  return {
    title,
    link: item.link,
    date: item.pagemap.metatags[0].date,
    image: item.pagemap.cse_image[0].src,
    author: item.pagemap.metatags[0].author
  }
}
331380
def find_write_contribs() -> None:
    """"""
    map_file_auth = {}  # type: Dict[str, List[str]]
    for filename in scantree('cltk'):
        filepath = filename.path  # type: str
        authors_list = get_authors(filepath)  # type: List[str]
        if authors_list:
            map_file_auth[filepath] = authors_list

    map_auth_file = defaultdict(list)  # type: Dict[str, List[str]]
    for file, authors_file in map_file_auth.items():
        for author in authors_file:
            map_auth_file[author].append(file)
    # now sort the str contents of the list value
    map_auth_file = sort_def_dict(map_auth_file)
    map_auth_file_sorted = sorted(map_auth_file.items())  # type: List[Tuple[str, List[str]]]
    map_auth_file = OrderedDict(map_auth_file_sorted)

    write_contribs(map_auth_file)
1138298
def _add_combine_info(output, combine_map, file_key):
    
    files_per_output = collections.defaultdict(list)
    for part_file, out_file in combine_map.items():
        files_per_output[out_file].append(part_file)
    out_by_file = collections.defaultdict(list)
    out = []
    for data in output:
        # Do not pass along nochrom, noanalysis regions
        if data["region"][0] not in ["nochrom", "noanalysis"]:
            cur_file = data[file_key]
            # If we didn't process, no need to add combine information
            if cur_file in combine_map:
                out_file = combine_map[cur_file]
                if "combine" not in data:
                    data["combine"] = {}
                data["combine"][file_key] = {"out": out_file,
                                             "extras": files_per_output.get(out_file, [])}
                out_by_file[out_file].append(data)
            elif cur_file:
                out_by_file[cur_file].append(data)
            else:
                out.append([data])
    for samples in out_by_file.values():
        regions = [x["region"] for x in samples]
        region_bams = [x["work_bam"] for x in samples]
        assert len(regions) == len(region_bams)
        if len(set(region_bams)) == 1:
            region_bams = [region_bams[0]]
        data = samples[0]
        data["region_bams"] = region_bams
        data["region"] = regions
        data = dd.set_mark_duplicates(data, data["config"]["algorithm"]["orig_markduplicates"])
        del data["config"]["algorithm"]["orig_markduplicates"]
        out.append([data])
    return out
137198
def import_authors(self, tree):
        
        self.write_out(self.style.STEP('- Importing authors\n'))

        post_authors = set()
        for item in tree.findall('channel/item'):
            post_type = item.find('{%s}post_type' % WP_NS).text
            if post_type == 'post':
                post_authors.add(item.find(
                    '{http://purl.org/dc/elements/1.1/}creator').text)

        self.write_out('> %i authors found.\n' % len(post_authors))

        authors = {}
        for post_author in post_authors:
            if self.default_author:
                authors[post_author] = self.default_author
            else:
                authors[post_author] = self.migrate_author(
                    post_author.replace(' ', '-'))
        return authors
811889
function compileKeys(urls) {
    return urls.map(function (url) {
        // replace named params with regexp groups
        var pattern = url[0].replace(/\/:\w+/g, '(?:/([^\/]+))');
        url[0] = new RegExp('^(?:' + pattern + ')$');
        return url;
    });
}
297723
def compile_authors(cell):
    
    logger_excel.info("enter compile_authors")
    author_lst = []
    s = cell.split(';')
    for w in s:
        author_lst.append(w.lstrip())
    logger_excel.info("exit compile_authors")
    return author_lst
524362
def compile_authors(authors):
    
    author_list = []
    for person in authors:
        author_list.append({'name': person['family'] + ", " + person['given']})
    return author_list
351568
function build_doc_map(docs) {
  var map = {};
  _.each(docs, function(tag) {
    if (map[tag["tagname"]])
      map[tag["tagname"]].push(tag);
    else
      map[tag["tagname"]] = new Array(tag);
  });
  return map;
}
445853
def map_with(*names)
      [self, *names.map { |name| mappers[name] }]
        .reduce { |a, e| composite_class.new(a, e) }
    end
712621
def group_by_source(self):
        """"""
        from collections import defaultdict
        docs = defaultdict(list)

        for k, v in self.items():
            if 'source' in v:
                docs[v.source].append(dict(v.items()))

        return docs
445439
def group2commdct(commdct, glist):
    """"""
    for (gname, objname), commitem in zip(glist, commdct):
        commitem[0]['group'] = gname
        commitem[0]['idfobj'] = objname
    return commdct
1362553
def make_map(declarations):
    """"""
    mapper = routes.Mapper()
    for route, methods in ROUTE_LIST:
        allowed_methods = []
        for method, func in methods.items():
            mapper.connect(route, action=func,
                           conditions=dict(method=[method]))
            allowed_methods.append(method)
        allowed_methods = ', '.join(allowed_methods)
        mapper.connect(route, action=handle_not_allowed,
                       _methods=allowed_methods)
    return mapper
875897
def compile_fetch(raw, doi_id):
    
    fetch_dict = OrderedDict()
    order = {'author': 'author', 'type': 'type', 'identifier': '', 'title': 'title', 'journal': 'container-title',
            'pubYear': '', 'volume': 'volume', 'publisher': 'publisher', 'page':'page', 'issue': 'issue'}

    for k, v in order.items():
        try:
            if k == 'identifier':
                fetch_dict[k] = [{"type": "doi", "id": doi_id, "url": "http://dx.doi.org/" + doi_id}]
            elif k == 'author':
                fetch_dict[k] = compile_authors(raw[v])
            elif k == 'pubYear':
                fetch_dict[k] = compile_date(raw['issued']['date-parts'])
            else:
                fetch_dict[k] = raw[v]
        except KeyError as e:
            # If we try to add a key that doesn't exist in the raw dict, then just keep going.
            pass
    return fetch_dict
1367955
@PostConstruct
	protected void buildCopyrightMap() {
		if (null == declaredPlugins) {
			return;
		}
		// go over all plug-ins, adding copyright info, avoiding duplicates (on object key)
		for (PluginInfo plugin : declaredPlugins.values()) {
			for (CopyrightInfo copyright : plugin.getCopyrightInfo()) {
				String key = copyright.getKey();
				String msg = copyright.getKey() + ": " + copyright.getCopyright() + " : licensed as " +
						copyright.getLicenseName() + ", see " + copyright.getLicenseUrl();
				if (null != copyright.getSourceUrl()) {
					msg += " source " + copyright.getSourceUrl();
				}
				if (!copyrightMap.containsKey(key)) {
					log.info(msg);
					copyrightMap.put(key, copyright);
				}
			}
		}
	}
221397
def build_contributors(authors, contrib_type, competing_interests=None):
    

    contributors = []

    for author in authors:
        contributor = None
        author_contrib_type = contrib_type

        surname = author.get("surname")
        given_name = author.get("given-names")
        collab = author.get("collab")

        # Small hack for on-behalf-of type when building authors
        #  use on-behalf-of as the contrib_type
        if author.get("type") and author.get("type") == "on-behalf-of":
            collab = author.get("on-behalf-of")
            author_contrib_type = "on-behalf-of"

        if surname or collab:
            contributor = ea.Contributor(author_contrib_type, surname, given_name, collab)

        utils.set_attr_if_value(contributor, 'suffix', author.get('suffix'))

        contributor.group_author_key = author.get("group-author-key")
        contributor.orcid = author.get("orcid")
        contributor.corresp = bool(author.get("corresp"))
        if author.get("equal-contrib") == "yes":
            contributor.equal_contrib = True

        # Add contributor affiliations
        for aff in author.get("affiliations", []):
            affiliation = ea.Affiliation()
            affiliation.text = utils.text_from_affiliation_elements(
                aff.get("dept"),
                aff.get("institution"),
                aff.get("city"),
                aff.get("country"))
            # fall back if no other fields are set take the text content
            if affiliation.text == '':
                affiliation.text = aff.get("text")
            contributor.set_affiliation(affiliation)

        # competing interests / conflicts
        if (competing_interests and author.get("references")
            and "competing-interest" in author.get("references")):
            for ref_id in author["references"]["competing-interest"]:
                for competing_interest in competing_interests:
                    if competing_interest.get("text") and competing_interest.get("id") == ref_id:
                        clean_text = utils.remove_tag('p', competing_interest.get("text"))
                        contributor.set_conflict(clean_text)

        # Finally add the contributor to the list
        if contributor:
            contributors.append(contributor)

    return contributors
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