-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalculate_crossref_bibtex_similarity.py
691 lines (555 loc) · 22.9 KB
/
calculate_crossref_bibtex_similarity.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
# -*- coding: utf-8 -*-
import re
import sys
import ast
import numpy as np
import pandas as pd
import string
import random
import json
import psycopg2
import binascii
import datetime
import traceback
import pandas.io.sql as pd_psql
"""
author: Haydar Akyürek
description:
Python 3 script to calculate similarity of crossref data with 'source' data.
Values retrieved from database dbexcitetest, tables: crossref_references_ha and join_ref_bibtex_match_ha
result dataframe saved as csv "crossrefvalue.csv"
run with python3 calculate_crossref_bibtex_similarity.py
BEFORE running: input login data for database access in line 28.
"""
next_prime = 4294967311
max_shingle_id = 2**32-1
def save_results_to_db(psql_login_data, dataframe):
try:
conn = psycopg2.connect(dbname=psql_login_data[0], user=psql_login_data[1], host=psql_login_data[2], password=psql_login_data[3])
except psycopg2.Error as e:
print ("Unable to connect!")
print (e)
sys.exit(1)
cursor = conn.cursor()
result_df = dataframe.loc[~dataframe['final_score']==False]
result_df = dataframe
#list_of_result_tuples = []
for ref_id_index, row in result_df.iterrows():
val = (int(str(ref_id_index)), str(row['checkdoi']), str(row['autscore']), str(row['title_score_85']), str(row['yearscore']))
#list_of_result_tuples.append(val)
cursor.execute('INSERT INTO similarity_matches_ha (ref_id, query_doi, query_author, query_title, query_year) VALUES '
'(%s, %s, %s, %s, %s)', val)
conn.commit()
conn.close()
def save_match_dict_to_db(psql_login_data, result_df):
try:
conn = psycopg2.connect(dbname=psql_login_data[0], user=psql_login_data[1], host=psql_login_data[2], password=psql_login_data[3])
except psycopg2.Error as e:
print ("Unable to connect!")
print (e)
sys.exit(1)
cursor = conn.cursor()
#value_dict = result_df.to_dict('index')
for ref_id_index, row in result_df.iterrows():
val_dict = {
'autscore' : row['autscore'],
'yearscore': row['yearscore'],
'checkdoi':row['checkdoi'],
'jaccard_score_title':row['jaccard_score_title'],
'title_score_85':row['title_score_85'],
'jaccard_score_journal':row['jaccard_score_journal'],
'journal_score_85':row['journal_score_85'],
'pagescore':row['pagescore'],
'volumscore':row['volumscore']
}
val = (int(str(ref_id_index)), json.dumps(val_dict), row['autscore'], row['yearscore'], row['checkdoi'],
row['jaccard_score_title'], row['title_score_85'], row['jaccard_score_journal'], row['journal_score_85'],
row['pagescore'], row['volumscore'])
#list_of_result_tuples.append(val)
cursor.execute('INSERT INTO match_results_ha(ref_id, match_dict,autscore,yearscore, checkdoi,'
'jaccard_score_title ,jaccard_title_85, jaccard_score_journal, jaccard_journal_85, '
'pagescore, volumescore) VALUES '
'(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', val)
conn.commit()
conn.close()
def normauthors_alg(item):
normalizedtitle = "".join(l for l in item if l not in string.punctuation)
normalizedtitle = normalizedtitle.lower()
normalizedtitle = normalizedtitle.replace(" ", "")
normalizedtitle=normalizedtitle.replace(u'ü', '')
normalizedtitle=normalizedtitle.replace(u'ä', '')
normalizedtitle=normalizedtitle.replace(u'ö', '')
normalizedtitle=normalizedtitle.replace(u'ß', 'ss')
normalizedtitle =''.join([i if ord(i) < 128 else '' for i in normalizedtitle])
return normalizedtitle
def Author_title(title,author):
normalizedtitle = "".join(l for l in title if l not in string.punctuation)
normalizedtitle = normalizedtitle.lower()
normalizedtitle = normalizedtitle.replace(" ", "")
normalizedtitle=normalizedtitle.replace(u'ü', 'u')
normalizedtitle=normalizedtitle.replace(u'ä', 'a')
normalizedtitle=normalizedtitle.replace(u'ö', 'o')
normalizedtitle=normalizedtitle.replace(u'ß', 'ss')
normalizedtitle =''.join([i if ord(i) < 128 else '' for i in normalizedtitle])
if isinstance(author, list):
new_autors = ','.join(l for l in author)
else:
new_autors = author
norm_authors=[]
for item in new_autors.split(','):
norm_authors.append(normauthors_alg(item.strip()))
return normalizedtitle, norm_authors
def normalize_input(title,author):
temprec = {}
ntitles, norm_authors = Author_title(title,author)
temprec["norm_title_str"] = ntitles
temprec["author_name"] = norm_authors
return temprec
def ref_hash_genrater(data1,item_ref):
COEFFS = data1.as_matrix()
COEFFS = COEFFS.tolist()
lsref_hash = []
minhash_list_ref_title = get_min_hash(item_ref['norm_title_str'], COEFFS, 3)
item_ref['hash_values'] = minhash_list_ref_title
return item_ref
def str_to_nr(text):
return binascii.crc32(bytes(text, 'utf-8') & 0xffffffff)
def get_min_hash(text, coeffs, n=3):
shingles = get_shingles(text, n)
lsr=[]
for coeff in coeffs:
lsr.append(hash_int(shingles, coeff))
return lsr
def get_shingles(text, n):
"""
Get integer representation of each shingle of a
text string
@param text: The text from which you want to get the represenation
@param n: The n for ngrams zou want to use
"""
text = "" if type(text) is float else text
return list({str_to_nr(text[max(0, p):p+n]) for
p in range(1-n, len(text))})
def hash_int(shingles, coeff):
temresult=[]
temresult.append(next_prime + 1)
for s in shingles:
cal=(coeff[0] * s + coeff[1]) % next_prime
temresult.append(int(cal))
return min(temresult)
def generate_coeffs(num_hashes=100):
"""
Generate the coefficients for the hash functions
@param num_hashes: The number of coeffiecient you want to generate
(k in literature)
@return A List of tuples of two randomly generated coefficients
with the size num_hashes
Example: [(302934, 2389881),(234209, 938990)]
"""
coeff_a = list()
while len(coeff_a) < 2*(num_hashes+1):
coeff_a.append(random.randint(0, max_shingle_id))
tem_lent=int(len(coeff_a) / 2)
coeff_a_1 = coeff_a[:tem_lent]
coeff_a_2 = coeff_a[tem_lent:]
coeffs = [c for c in zip(coeff_a_1, coeff_a_2)]
return coeffs
def compare_min_hash(one, two):
"""
Comparing two hashes
@return the approximated jaccard distance generated from two hashes
"""
nr_same = sum([1 for nr in range(len(one)) if
one[nr] == two[nr]])
return float(float(nr_same)/len(one))
def Crossrefdoiextractor(text):
dictcross=json.loads(text)
if len(dictcross)>0:
if "DOI" in dictcross.keys():
return dictcross["DOI"]
else:
return np.nan
else:
return np.nan
def str_to_nr(text):
return binascii.crc32(bytes(text, "utf-8")) & 0xffffffff
def get_shingles(text, n):
"""
Get integer representation of each shingle of a
text string
@param text: The text from which you want to get the represenation
@param n: The n for ngrams zou want to use
"""
text = "" if type(text) is float else text
return list({str_to_nr(text[max(0, p):p+n]) for
p in range(1-n, len(text))})
def DistJaccard(list1, list2):
str1 = set(list1)
str2 = set(list2)
return float(len(str1 & str2)) / len(str1 | str2)
def author_crossref(text):
ls_aut=[]
dictcross=json.loads(text)
if len(dictcross)>0:
if "author" in dictcross.keys():
for item in dictcross["author"]:
if 'family' in item.keys():
ls_aut.append(item['family'])
else:
return np.nan
else:
return np.nan
strtext=""
if len(ls_aut):
for item in ls_aut:
if strtext=="":
pass
else:
strtext=strtext+","
strtext=strtext+item
else:
return np.nan
testtitle=""
testauthor=strtext
Ref_norm=normalize_input(testtitle,testauthor)
return Ref_norm['author_name']
def journal_crossref(text):
ls_title = []
dictcross = json.loads(text)
if len(dictcross) > 0:
if "container-title" in dictcross.keys():
for item in dictcross["container-title"]:
ls_title.append(item)
else:
return np.nan
else:
return np.nan
ls_normtitle = []
for item in ls_title:
testtitle = item
testauthor = ""
Ref_norm = normalize_input(testtitle, testauthor)
ls_normtitle.append(Ref_norm['norm_title_str'])
return ls_normtitle
def norm_journal(df):
testtitle=df
testauthor=""
ls_normjournal=[]
for title in testtitle:
t, a = Author_title(title,testauthor)
#Ref_norm=normalize_input(testtitle,testauthor)
#Exctie_journal=Ref_norm["norm_title_str"]
ls_normjournal.append(t)
result = "".join(ls_normjournal)
if len(result.strip()) > 0:
return result
else:
return np.nan
def jaccard_journal(df):
import ast
list_titlecrossref=df["crossref_journal"]
Exctie_journal=df["journals_norm"]
if len(Exctie_journal)<1 or len(list_titlecrossref)<1:
return 0
else:
try:
lsminhashscore=[]
for item in list_titlecrossref:
lsminhashscore.append(DistJaccard(get_shingles(Exctie_journal,3),get_shingles(item,3)))
except Exception as e:
print (str(e))
print ("\n")
traceback.print_exc(file=sys.stdout)
print("================")
if len(lsminhashscore) > 0:
return max(lsminhashscore)
else: return 0
def title_crossref(text):
ls_title=[]
dictcross=json.loads(text)
if len(dictcross)>0:
if "title" in dictcross.keys():
for item in dictcross["title"]:
ls_title.append(item)
else:
return np.nan
else:
return np.nan
ls_normtitle=[]
for item in ls_title:
testtitle=item
testauthor=""
Ref_norm=normalize_input(testtitle,testauthor)
ls_normtitle.append(Ref_norm['norm_title_str'])
return ls_normtitle
def filter_year(list_date):
now = datetime.datetime.now()
currentyear=now.year
currentyear=int(currentyear)
ls_year=[]
for date in list_date:
for year in date:
try:
if int(year)>1200:
if int(year)==currentyear or currentyear>int(year):
ls_year.append(year)
else:
pass
except:
pass
return ls_year
def crossref_year(text):
dictcross=json.loads(text)
if len(dictcross)>0:
if "issued" in dictcross.keys():
if 'date-parts' in dictcross["issued"]:
lsyearfilter=filter_year(dictcross["issued"]["date-parts"])
if len(lsyearfilter)>0:
return lsyearfilter
else:
return np.nan
else:
return np.nan
else:
return np.nan
else:
return np.nan
def Max_minhash_titles(df):
list_titlecrossref=df["crossref_title"]
testtitle=df["title"]
testauthor=""
Ref_norm=normalize_input(testtitle,testauthor)
Exctie_title=Ref_norm["norm_title_str"]
try:
lsminhashscore=[]
ref1 = {}
ref1["norm_title_str"] = Exctie_title
ref1=ref_hash_genrater(data1,ref1)
for item in list_titlecrossref:
ref2 = {}
ref2["norm_title_str"] = item
ref2=ref_hash_genrater(data1,ref2)
lsminhashscore.append(compare_min_hash(ref2["hash_values"],ref1["hash_values"]))
except:
print("======")
print(list_titlecrossref)
print(Exctie_title)
print("================")
return max(lsminhashscore)
def jaccard_titles(df):
list_titlecrossref=df["crossref_title"]
testtitle=df["title"]
testauthor=""
Ref_norm=normalize_input(testtitle,testauthor)
Exctie_title=Ref_norm["norm_title_str"]
try:
lsminhashscore=[]
for item in list_titlecrossref:
lsminhashscore.append(DistJaccard(get_shingles(Exctie_title,3),get_shingles(item,3)))
except Exception as e:
print (str(e))
print ("\n")
traceback.print_exc(file=sys.stdout)
print("================")
if len(lsminhashscore) > 0:
return max(lsminhashscore)
else: return 0
def filteryear2(itemyear):
year = ''
try:
if 1000<int(itemyear) and 3000>int(itemyear):
year=itemyear
except:
pass
return year
def checkyear(Year_item):
listofyear=[]
for itemyis in Year_item:
for itemyis_s in itemyis.split(' '):
item_iter_year=filteryear2(itemyis_s)
if item_iter_year!="":
listofyear.append(int(item_iter_year))
return listofyear
def intersectyear(a):
anb = set(a["crossref_year"]) & set(a["clean_year"])
if anb:
return True
else:
return False
def intersectaut(a):
anb = set(a["crossref_author"]) & set(a["norm_aut"])
if anb:
return True
else:
return False
def intersectvolume_numbers(a):
anb = set(a["crossref_volume"]) & set(a["volume_numbers"])
if anb:
return True
else:
return False
def intersectpages(a):
anb = set(a["crossref_page"]) & set(a["pages"])
if anb:
return True
else:
return False
def normalise_pages(page):
results = [int(i) for i in re.findall(r'\d+', str(page))]
return results
def normalise_crossref_pages(text):
dictcross = json.loads(text)
pages = []
if len(dictcross) > 0:
if "page" in dictcross.keys():
page_str = dictcross["page"]
pages = [int(i) for i in re.findall(r'\d+', str(page_str))]
return pages
def normalise_crossref_volume(text):
dictcross = json.loads(text)
vol = []
if len(dictcross) > 0:
if "volume" in dictcross.keys():
vol_str = dictcross["volume"]
vol = [int(i) for i in re.findall(r'\d+', str(vol_str))]
return vol
def compare_page_numbers(t_pages, cr_pages):
return len(set(t_pages).intersection(cr_pages)) > 0
def extracted_aut(text):
testtitle=""
testauthor=text
Ref_norm=normalize_input(testtitle,testauthor)
return Ref_norm["author_name"]
def calculate_similarity(psql_login_data, chunk_size=25000):
try:
conn = psycopg2.connect(dbname=psql_login_data[0], user=psql_login_data[1], host=psql_login_data[2], password=psql_login_data[3])
except psycopg2.Error as e:
print("Unable to connect!")
print(e)
sys.exit(1)
bibtex_fetch = 0
crossref_fetch = 0
offset = 0
cursor = conn.cursor()
cursor.execute("DROP TABLE IF EXISTS similarity_matches_ha;")
cursor.execute("CREATE TABLE IF NOT EXISTS similarity_matches_ha "
"("
"ref_id INTEGER NOT NULL, "
"query_doi TEXT, "
"query_author TEXT, "
"query_title TEXT, "
"query_year TEXT "
");")
conn.commit()
cursor.execute("DROP TABLE IF EXISTS match_results_ha;")
cursor.execute("CREATE TABLE IF NOT EXISTS match_results_ha "
"("
"ref_id INTEGER PRIMARY KEY NOT NULL, "
"match_dict TEXT, "
"autscore BOOLEAN, "
"yearscore BOOLEAN, "
"checkdoi BOOLEAN, "
"jaccard_score_title NUMERIC , "
"jaccard_title_85 BOOLEAN , "
"jaccard_score_journal NUMERIC , "
"jaccard_journal_85 BOOLEAN , "
"pagescore BOOLEAN,"
"volumescore BOOLEAN "
");")
conn.commit()
cursor.execute("SELECT COUNT(*) FROM crossref_references_ha;")
total_length = cursor.fetchone()[0]
#total_length = 100000
cnt = 0
while True:
cnt +=1
# cancel execution: end of table reached
if offset >= total_length:
break
# --- read dataframes ---
sql = "SELECT ref_id, crossref_value_json FROM crossref_references_ha ORDER BY ref_id ASC OFFSET %d LIMIT %d " % (offset, chunk_size)
crossref_data = pd_psql.read_sql(sql, conn)
crossref_fetch += len(crossref_data)
print("offset old: ", offset, "offset new: ", str(offset+chunk_size), " total length: ", total_length)
offset += chunk_size
# transform ref_id column of the match_info dataframe into a python list
ref_id_numpy = crossref_data['ref_id'].tolist()
ref_id_list = [int(str(x)) for x in ref_id_numpy]
# get all crossref values, where ref_id matches the ref_id of the 'match_info' dataframe
sql = "select * from join_ref_bibtex_match_ha where ref_id in %s"
match_info = pd.read_sql(sql, conn, params=[tuple(ref_id_list)])
bibtex_fetch += len(match_info)
# resign index columns
crossref_data.set_index("ref_id", inplace=True)
# match_info =pd.read_csv("bibtex_ha.csv", sep=",")
match_info.set_index("ref_id", inplace=True)
# append crossref json to match_info dataframe.
match_info["crossref"] = np.nan
match_info["crossref"] = crossref_data["crossref_value_json"]
if len(match_info) > 0:
result_df = calcu_sim(match_info)
save_match_dict_to_db(psql_login_data, result_df)
match_info = None
crossref_data = None
def calcu_sim(joined_table):
#COEFFS = generate_coeffs()
#df3 = pd.DataFrame(COEFFS)
#df3.to_csv('list_of_coeeff.csv', index=False)
crossrefvalue=joined_table[~joined_table["crossref"].isnull()] #9197
# --- extract DOI ---
crossrefvalue["crossrefdoi"]=crossrefvalue["crossref"].apply(Crossrefdoiextractor)
checkdoi=crossrefvalue[~crossrefvalue["crossrefdoi"].isnull()][~crossrefvalue["doi"].isnull()]
checkdoi["checkdoi"]=checkdoi["crossrefdoi"]==checkdoi["doi"]
crossrefvalue["checkdoi"]=checkdoi["checkdoi"]
# --- extract author ---
crossrefvalue["crossref_author"]=crossrefvalue["crossref"].apply(author_crossref)
crossrefvalue.to_pickle('cr.pkl')
# --- extract title ---
crossrefvalue["crossref_title"]=crossrefvalue["crossref"].apply(title_crossref)
# --- extract journal ---
crossrefvalue["journals_norm"] = crossrefvalue['journals'].apply(norm_journal)
crossrefvalue["crossref_journal"] = crossrefvalue["crossref"].apply(journal_crossref)
# --- extract year ---
crossrefvalue["crossref_year"]=crossrefvalue["crossref"].apply(crossref_year)
crossrefvalue["crossref_len_title"]=crossrefvalue[~crossrefvalue["crossref_title"].isnull()]["crossref_title"].apply(len)
#data1 = pd.read_csv('list_of_coeeff.csv')
# --- calculate jaccard ---
cross_title = crossrefvalue[~crossrefvalue["crossref_title"].isnull()][~crossrefvalue["title"].isnull()]
crossrefvalue["jaccard_score_title"]=cross_title.apply(jaccard_titles, axis=1)
crossrefvalue["title_score_85"]=crossrefvalue["jaccard_score_title"]>=0.85
crossrefvalue["jaccard_score_journal"] = crossrefvalue[~crossrefvalue["crossref_journal"].isnull()][~crossrefvalue["journals_norm"].isnull()].apply(
jaccard_journal, axis=1)
crossrefvalue["journal_score_85"] = crossrefvalue["jaccard_score_journal"] >=0.85
# --- check pages
crossrefvalue['pages'] =crossrefvalue["pages"].apply(normalise_pages)
crossrefvalue['volume'] = crossrefvalue['volume'].apply(normalise_pages)
crossrefvalue['numbers'] = crossrefvalue['numbers'].apply(normalise_pages)
crossrefvalue['volume_numbers'] = crossrefvalue['volume'] + crossrefvalue['numbers']
crossrefvalue['crossref_page'] = crossrefvalue["crossref"].apply(normalise_crossref_pages)
crossrefvalue['crossref_volume'] = crossrefvalue["crossref"].apply(normalise_crossref_volume)
crossrefvalue["pagescore"] = crossrefvalue.apply(intersectpages, axis=1)
crossrefvalue["volumscore"] = crossrefvalue.apply(intersectvolume_numbers, axis=1)
# --- check year ---
crossrefvalue["clean_year"]=crossrefvalue["year"].apply(checkyear)
crossrefvalue["yearscore"]=crossrefvalue[~crossrefvalue["clean_year"].isnull()][~crossrefvalue["crossref_year"].isnull()].apply(intersectyear, axis=1)
crossrefvalue["norm_aut"]=crossrefvalue["author_name"].apply(extracted_aut)
crossrefvalue["autscore"]=crossrefvalue[~crossrefvalue["norm_aut"].isnull()][~crossrefvalue["crossref_author"].isnull()].apply(intersectaut, axis=1)
crossrefvalue["autscore"]=crossrefvalue["autscore"].fillna(False)
crossrefvalue["yearscore"]=crossrefvalue["yearscore"].fillna(False)
crossrefvalue["title_score_85"]=crossrefvalue["title_score_85"].fillna(False)
crossrefvalue["final_score_yta"]= (crossrefvalue["autscore"] & crossrefvalue["title_score_85"]) | (crossrefvalue["yearscore"] & crossrefvalue["title_score_85"])
crossrefvalue["checkdoi"]=crossrefvalue["checkdoi"].fillna(False)
crossrefvalue["match_id"]=crossrefvalue["match_id"].fillna(False)
crossrefvalue["jaccard_score_journal"] = crossrefvalue["jaccard_score_journal"].fillna(0)
crossrefvalue["jaccard_score_title"] = crossrefvalue["jaccard_score_title"].fillna(0)
# --- shrink dataframe
shrinked_crossvalue = crossrefvalue[['autscore', 'yearscore',
'checkdoi', 'jaccard_score_title','title_score_85',
'jaccard_score_journal','journal_score_85',
'pagescore', 'volumscore']]
return shrinked_crossvalue
"""
if __name__ == '__main__':
psql_login_data = ["db", "user", "host", "pass"]
calculate_similarity(None, 50000)
"""