SHARE
TWEET

Untitled

a guest Oct 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import json
  2. import sys
  3.  
  4. if __name__ == '__main__':
  5.     #sys.stdin = open('in.txt', 'r')
  6.     n = int(input())
  7.  
  8.     l = []
  9.  
  10.     for i in range(n):
  11.         l.append(input())
  12.  
  13.     y = json.loads(l[0])
  14.  
  15.     nbcit = 0
  16.     dicPub = {}
  17.     dicPubValues = {}
  18.     pub_one = json.loads(l[0])
  19.  
  20.     for i in pub_one['publications']:
  21.         # print(i)
  22.         dicPub[i['publicationNumber']] = i['publicationTitle']
  23.         year_list = i['articleCounts']
  24.         for j in year_list:
  25.             #  print(j)
  26.             if int(j['year']) == 2017 or int(j['year']) == 2018:
  27.                 if i['publicationNumber'] not in dicPubValues.keys():
  28.                     dicPubValues[i['publicationNumber']] = 0
  29.                 dicPubValues[i['publicationNumber']] += int(j['articleCount'])
  30.  
  31.     dicCit = {}
  32.     for i in range(1, n):
  33.         y = json.loads(l[i])
  34.         o = y["paperCitations"]
  35.         for i in o['ieee']:
  36.             # print(i)
  37.             if int(i['year']) == 2017 or int(i['year']) == 2018:
  38.                 if i['publicationNumber'] not in dicCit.keys():
  39.                     dicCit[i['publicationNumber']] = 0
  40.                 dicCit[i['publicationNumber']] += 1
  41.  
  42.     # print(dicCit)
  43.     #  print(dicPub)
  44.     #  print(dicPubValues)
  45.  
  46.     finalList = []
  47.     for key in dicPubValues.keys():
  48.         x = (dicCit[key] / dicPubValues[key])
  49.         s = (dicPub[key], round(x, 2))
  50.         #   s = ('{}: {:.2f}'.format(dicPub[key], round(x, 2)))
  51.         touched = False
  52.         if len(finalList) == 0:
  53.             finalList.insert(0, s)
  54.         else:
  55.             for i, value in enumerate(finalList):
  56.                 if value[1] <= s[1]:
  57.                     finalList.insert(i, s)
  58.                     touched = True
  59.                     break
  60.  
  61.             if not touched:
  62.                 finalList.append(s)
  63.  
  64.  
  65.                 #  finalList.append(s)
  66.  
  67.     for s in finalList:
  68.         print("{}: {:.2f}".format(s[0] , s[1]))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top