forked from janczizikow/sleek
-
Notifications
You must be signed in to change notification settings - Fork 0
/
repAuthors.m
42 lines (28 loc) · 995 Bytes
/
repAuthors.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
%%
repRoot = '/Users/nick/github/Steinmetzlab.github.io/';
q = loadjson(fullfile(repRoot, '_data/oldPubs.json'));
%%
for n = 1:numel(q.papers)
s = q.papers{n}.authors;
ss = strsplit(strrep(strrep(s, '<b>', ''), '</b>', ''), ', ');
noInits = cellfun(@(x)strsplit(x,' '), ss, 'uni', false);
for x = 1:numel(noInits)
if strcmp(noInits{x}{1}, 'et')
noInits{x} = 'et al.';
elseif numel(noInits{x})>1 && contains(noInits{x}{2}, '*')
noInits{x} = [noInits{x}{1} '*'];
else
noInits{x} = noInits{x}{1};
end
end
% noInits = cellfun(@(x)x{1}, noInits, 'uni', false);
q.papers{n}.authors = ss;
q.papers{n}.authors_short = noInits;
% also fix tags??
q.papers{n}.tags = cellfun(@(x)x{1}, q.papers{n}.tags, 'uni', false);
end
%%
j = savejson('', q);
j = strrep(j, '\/', '/'); % wtf
fid = fopen(fullfile(repRoot, '_data/pubs.json'), 'w');
fwrite(fid, j, 'char');