get-paper-tree

This is an improved version of the repo "collection-of-paper".

https://github.com/koyo526/get-paper-tree

Science Score: 18.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (2.6%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

This is an improved version of the repo "collection-of-paper".

Basic Info
  • Host: GitHub
  • Owner: Koyo526
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 51.8 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 2 years ago · Last pushed over 2 years ago
Metadata Files
Readme License Citation

README.md

get-paper-tree

This is an improved version of the repo koyo526/collection-of-paper. This system uses Semantic Scholar's WebAPI.
More detail: https://api.semanticscholar.org/api-docs/graph

Owner

  • Login: Koyo526
  • Kind: user

Citation (citation.py)

import requests
import json
from requests.exceptions import RequestException, ConnectionError, HTTPError, Timeout
from urllib3.util import Retry
from requests.adapters import HTTPAdapter

class Citation():
    def __init__(self,id):
        self.paperId = id
        self.headers = {"""YOUR API KEY"""}
        self.endpoint = f'https://api.semanticscholar.org/graph/v1/paper/{self.paperId}/citations'
        self.fields = ('title', 'year', 'referenceCount', 'citationCount','influentialCitationCount',
                       'isOpenAccess', 'fieldsOfStudy', 'authors','abstract','url')
        self.params = {
            'fields': ','.join(self.fields),
            'limit': 10
            }
        
    def search_citing_papers(self):
        try:
            session = requests.Session()
            retries = Retry(total=5,backoff_factor=1,status_forcelist=[500, 502, 503, 504]) 
            session.mount("https://", HTTPAdapter(max_retries=retries))
            res = session.get(url=self.endpoint, params=self.params,stream=True,headers=self.headers,timeout=(10.0, 30.0))
            print(res.status_code)
            print(res.encoding)
            print(res.raise_for_status())
            res_dict = json.loads(res.text)
            dir = "citations.json"
            data = res_dict	# 任意のdict型変数
            with open(dir, mode="wt", encoding="utf-8") as f:
                json.dump(data, f, ensure_ascii=False, indent=2)
            return res_dict
        except ConnectionError as ce:
            print("Connection Error:", ce)
        except HTTPError as he:
            print("HTTP Error:", he)
        except Timeout as te:
            print("Timeout Error:", te)
        except RequestException as re:
            print("Error:", re)

    def print_citing_papers(self,r_dict):
        data = r_dict['data']
        for d in data:
            print('---------------')
            d = d['citingPaper']
            for fi in self.fields:
                if fi == 'authors':
                    print(f'{fi}: {list(map(lambda a: a["name"], d[fi]))}')
                else:
                    print(f'{fi}: {d[fi]}')
            print(f'paperID:{d["paperId"]}')

if __name__ == "__main__": 
    keyword = "a97ab7839888fe563f8f1fc7add057cbc8249510"
    S = Citation(keyword) 
    dic = S.search_citing_papers()
    S.print_citing_papers(dic)

GitHub Events

Total
Last Year