-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_netCountries.py
executable file
·53 lines (42 loc) · 1.62 KB
/
make_netCountries.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
#!/usr/bin/env python
from src.hepsearch import *
import pickle, os.path, sys, csv
# Get the collaboration matrix from file
file_name = 'data/countries_connections.dat'
if os.path.isfile(file_name):
file_obj = open(file_name,'rb')
Matrix = pickle.load(file_obj)
file_obj.close()
else:
sys.exit("ERROR: Connections info doesn't exist. Run first get_hepCountry.py")
# Check if Countries info exists
file_name = 'data/Countries.dat'
if os.path.isfile(file_name):
file_obj = open(file_name,'rb')
countries_list = pickle.load(file_obj)
file_obj.close()
else:
sys.exit("ERROR: Countries info doesn't exist. Run first get_hepCountry.py")
file_name = 'data/FAEmembers.dat'
if os.path.isfile(file_name):
file_obj = open(file_name,'rb')
author_list = pickle.load(file_obj)
file_obj.close()
else:
sys.exit("ERROR: Authors info doesn't exist. Run first get_hepAuthor.")
for y in range(len(countries_list)):
colaboradores = []
papers = 0
no_repetidos = []
for x in range(len(author_list)):
if author_list[x].num_papers != 0 and countries_list[y].num_papers != 0:
if len(Matrix[y][x]) != 0:
colaboradores.append(author_list[x].name)
papers += len(Matrix[y][x])
for z in range(len(Matrix[y][x])):
if not Matrix[y][x][z].title in no_repetidos:
no_repetidos.append(Matrix[y][x][z].title)
if len(colaboradores) != 0:
print 'Colaboracion con ', countries_list[y].name, ', Colaboradores:', len(colaboradores),\
", Papers:",len(no_repetidos)
# print "\t",colaboradores