题目描述
Click here to learn more about Xplore API
The IEEE Xplore Application Programming Interface (API) is an efficient data delivery vehicle for content indexing/discovery as well as text and data mining of IEEE metadata content of academic publications. Loading a database/repository using the content delivered by the IEEE API can be subsequently used to draw domain/subject relationships, data analytics, and various other use cases for researchers. To learn more about the IEEE Xplore API please visit developer.ieee.org and register for an API key. All participants of the IEEEXtreme 12.0 competition will have access to the IEEE API during and after the competition, for a limited period of time, to discover its research utility potential.
A useful metric commonly associated with academic publishing is the h-index. An author with an index of h has published h papers each of which has been cited in other papers at least h times.
For this challenge, write a program that reads a set of N entries from the Xplore database, in a JSON format, and prints ALL author names followed by the their h-index. The authors should be raked by h-index and by alphabetical order in case of an h-index tie.
输入
The input will consist of an integer N , followed by N lines with a single article entry in each line in a JSON format.
Each entry will follow a format described in the Xplore API website: developer.ieee.org/docs/read/metadata_API_responses
输出
Print the authors ranked by their h-index followed by a space and by the h-index itself. The authors should be ranked alphabetically if there are ties.
样例输入
10
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Echo"}, {"author_order": 2,"affiliation": "","full_name": "Bravo"}, {"author_order": 3,"affiliation": "","full_name": "Alfa"}]},"title": "Article Title 1","article_number": "1","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 9,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Charlie"}, {"author_order": 2,"affiliation": "","full_name": "Bravo"}]},"title": "Article Title 2","article_number": "2","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 9,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Echo"}, {"author_order": 2,"affiliation": "","full_name": "Delta"}, {"author_order": 3,"affiliation": "","full_name": "Alfa"}, {"author_order": 4,"affiliation": "","full_name": "Charlie"}]},"title": "Article Title 3","article_number": "3","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 4,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Charlie"}]},"title": "Article Title 4","article_number": "4","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 9,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Charlie"}, {"author_order": 2,"affiliation": "","full_name": "Echo"}, {"author_order": 3,"affiliation": "","full_name": "Alfa"}]},"title": "Article Title 5","article_number": "5","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 5,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Charlie"}, {"author_order": 2,"affiliation": "","full_name": "Echo"}]},"title": "Article Title 6","article_number": "6","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 6,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Delta"}]},"title": "Article Title 7","article_number": "7","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 4,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Charlie"}]},"title": "Article Title 8","article_number": "8","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 9,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Delta"}, {"author_order": 2,"affiliation": "","full_name": "Charlie"}]},"title": "Article Title 9","article_number": "9","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 4,"publisher": "IEEE"}
{"authors": {"authors": [{"author_order": 1,"affiliation": "","full_name": "Bravo"}, {"author_order": 2,"affiliation": "","full_name": "Echo"}]},"title": "Article Title 10","article_number": "10","publication_title": "Publication Title 1","publication_number": "7","citing_paper_count": 6,"publisher": "IEEE"}
样例输出
Charlie 5
Echo 4
Alfa 3
Bravo 3
Delta 3
提示
In this list, Charlie is the author of 7 papers: with article_number 2, 3, 4, 5, 6, 8, and 9. His papers have citation counts of 9, 4, 9, 5, 6, 9, and 4 respectively.
If we order his papers by citation count it will be: 9, 9, 9, 6, 5, 4, 4. Charlie's h-index is 5 Because he has 5 papers with at least 5 citations.
The same method is applied for Echo, Alfa, Bravo, and Delta. Because Alfa, Bravo, and Delta all have the same h-index they are listed alphabetically.
The N must be in 2<=N<=10000.
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 27 20:40:59 2023
@author: lenovo
"""
import json
class data:
def __init__(self, name, num):
self.name = name
self.num = num
n = int(input())
l = list()
while n > 0:
s = str(input())
json_data = json.loads(s)
l.append(json_data)
n = n - 1
name = list()
cite_num = list()
for i in range(len(l)):
l2 = l[i]['authors']['authors']
for j in range(len(l2)):
name.append(l2[j]['full_name'])
cite_num.append(l[i]['citing_paper_count'])
d = {}
for i in range(len(name)):
if name[i] in d:
l = d[name[i]]
l.append(cite_num[i])
d[name[i]] = l
else:
l = list()
l.append(cite_num[i])
d[name[i]] = l
d2 = {}
for key in d:
l3 = d[key]
l3.sort(reverse=True)
h_index = 0
for i in range(len(l3)):
if l3[i] >= i+1:
h_index = h_index+1
d2[key] = -1*h_index
tmp = []
for key in d2:
tmp.append(data(key, d2[key]))
tmp = sorted(tmp, key=lambda x: (x.num, x.name))
for i in range(len(tmp)):
print(tmp[i].name + " " + str(-1*tmp[i].num))