|
7 | 7 | from fuzzywuzzy import fuzz, process |
8 | 8 | import subprocess as sp |
9 | 9 |
|
10 | | -# These ORCIDs should go last |
| 10 | +# These names should go last |
11 | 11 | CREATORS_LAST = ['Gorgolewski, Krzysztof J.', 'Ghosh, Satrajit'] |
12 | | -# for entries not found in line-contributions |
13 | | -MISSING_ENTRIES = [ |
14 | | - {"name": "Varada, Jan"}, |
15 | | - {"name": "Schwabacher, Isaac"}, |
16 | | - {"affiliation": "Child Mind Institute / Nathan Kline Institute", |
17 | | - "name": "Pellman, John", |
18 | | - "orcid": "0000-0001-6810-4461"}, |
19 | | - {"name": "Khanuja, Ranjeet"}, |
20 | | - {"affiliation": |
21 | | - "Medical Imaging & Biomarkers, Bioclinica, Newark, CA, USA.", |
22 | | - "name": "Pannetier, Nicolas", |
23 | | - "orcid": "0000-0002-0744-5155"}, |
24 | | - {"name": "McDermottroe, Conor"}, |
25 | | - {"affiliation": |
26 | | - "Max Planck Institute for Human Cognitive and Brain Sciences, " |
27 | | - "Leipzig, Germany.", |
28 | | - "name": "Mihai, Paul Glad", |
29 | | - "orcid": "0000-0001-5715-6442"}, |
30 | | - {"name": "Lai, Jeff"} |
31 | | -] |
32 | 12 |
|
33 | 13 | if __name__ == '__main__': |
34 | 14 | contrib_file = Path('line-contributors.txt') |
|
55 | 35 | zenodo = json.loads(zenodo_file.read_text()) |
56 | 36 | zen_names = [' '.join(val['name'].split(',')[::-1]).strip() |
57 | 37 | for val in zenodo['creators']] |
58 | | - total_names = len(zen_names) + len(MISSING_ENTRIES) |
| 38 | + total_names = len(zen_names) |
59 | 39 |
|
60 | 40 | name_matches = [] |
61 | 41 | position = 1 |
62 | 42 | for ele in data: |
63 | 43 | matches = process.extract(ele, zen_names, scorer=fuzz.token_sort_ratio, |
64 | 44 | limit=2) |
65 | 45 | # matches is a list [('First match', % Match), ('Second match', % Match)] |
66 | | - if matches[0][1] > 80: |
67 | | - val = zenodo['creators'][zen_names.index(matches[0][0])] |
68 | | - else: |
| 46 | + if matches[0][1] <= 80: |
69 | 47 | # skip unmatched names |
70 | 48 | print("No entry to sort:", ele) |
71 | 49 | continue |
72 | 50 |
|
| 51 | + idx = zen_names.index(matches[0][0]) |
| 52 | + val = zenodo['creators'][idx] |
| 53 | + |
73 | 54 | if val not in name_matches: |
74 | 55 | if val['name'] not in CREATORS_LAST: |
75 | 56 | val['position'] = position |
|
78 | 59 | val['position'] = total_names + CREATORS_LAST.index(val['name']) |
79 | 60 | name_matches.append(val) |
80 | 61 |
|
81 | | - for missing in MISSING_ENTRIES: |
82 | | - missing['position'] = position |
83 | | - position += 1 |
84 | | - name_matches.append(missing) |
| 62 | + for missing in zenodo['creators']: |
| 63 | + if 'position' not in missing: |
| 64 | + missing['position'] = position |
| 65 | + position += 1 |
| 66 | + name_matches.append(missing) |
85 | 67 |
|
86 | 68 | zenodo['creators'] = sorted(name_matches, key=lambda k: k['position']) |
87 | 69 | # Remove position |
|
0 commit comments