Skip to content

Commit

Permalink
feat: get details about a paper's citations
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Jan 23, 2023
1 parent 6b4f2c7 commit 0397761
Show file tree
Hide file tree
Showing 5 changed files with 168,436 additions and 0 deletions.
13 changes: 13 additions & 0 deletions semanticscholar/Citation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from semanticscholar.Paper import Paper
from semanticscholar.BaseReference import BaseReference


class Citation(BaseReference):
'''
This class abstracts a citation.
'''

def __init__(self, data: dict) -> None:
super().__init__(data)
if 'citingPaper' in data:
self._paper = Paper(data['citingPaper'])
46 changes: 46 additions & 0 deletions semanticscholar/SemanticScholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from semanticscholar.ApiRequester import ApiRequester
from semanticscholar.Author import Author
from semanticscholar.BaseReference import BaseReference
from semanticscholar.Citation import Citation
from semanticscholar.PaginatedResults import PaginatedResults
from semanticscholar.Paper import Paper
from semanticscholar.Reference import Reference
Expand Down Expand Up @@ -155,6 +156,51 @@ def get_papers(

return papers

def get_paper_citations(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
) -> PaginatedResults:
'''Get details about a paper's citations
:calls: `POST /paper/{paper_id}/citations \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_paper_citations>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
PMID, PMCID, or URL from:
- semanticscholar.org
- arxiv.org
- aclweb.org
- acm.org
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
(must be <= 1000).
'''

if limit < 1 or limit > 1000:
raise ValueError(
'The limit parameter must be between 1 and 1000 inclusive.')

if not fields:
fields = BaseReference.FIELDS + Paper.SEARCH_FIELDS

url = f'{self.api_url}/paper/{paper_id}/citations'

results = PaginatedResults(
requester=self._requester,
data_type=Citation,
url=url,
fields=fields,
limit=limit
)

return results

def get_paper_references(
self,
paper_id: str,
Expand Down
1 change: 1 addition & 0 deletions tests/data/Citation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"isInfluential": true, "contexts": ["later introduced some changes to the original Transformer by utilizing only the decoder part of the transformer and applying causal masking [15].", "In particular, an autoregressive model termed Generative Pre-trained Transformer (GPT) [15] is responsible for significant breakthrough in textto-image [16] and language models [17].", "A GPT architecture later introduced some changes to the original Transformer by utilizing only the decoder part of the transformer and applying causal masking [15].", "The DT, based on the GPT architecture, is illustrated in Fig.", "(GPT) [15] is responsible for significant breakthrough in textto-image [16] and language models [17].", "In particular, the DT architecture, based on GPT, was chosen to be with embedded dimension of 128, 1 hidden layer, 1 attention head and a ReLU activation function."], "intents": ["methodology", "background"], "citingPaper": {"paperId": "bdcbc589c8d1e4dd0c6572630f8511557406ad2f", "externalIds": {"DBLP": "journals/ral/MonastirskyAS23", "DOI": "10.1109/LRA.2022.3229266", "CorpusId": 254723237}, "corpusId": 254723237, "publicationVenue": {"id": "93c335b7-edf4-45f5-8ddc-7c5835154945", "name": "IEEE Robotics and Automation Letters", "alternate_names": ["IEEE Robot Autom Lett"], "issn": "2377-3766", "url": "https://www.ieee.org/membership-catalog/productdetail/showProductDetailPage.html?product=PER481-ELE", "alternate_urls": ["http://ieeexplore.ieee.org/servlet/opac?punumber=7083369"]}, "url": "https://www.semanticscholar.org/paper/bdcbc589c8d1e4dd0c6572630f8511557406ad2f", "title": "Learning to Throw With a Handful of Samples Using Decision Transformers", "abstract": "Throwing objects by a robot extends its reach and has many industrial applications. While analytical models can provide efficient performance, they require accurate estimation of system parameters. Reinforcement Learning (RL) algorithms can provide an accurate throwing policy without prior knowledge. However, they require an extensive amount of real world samples which may be time consuming and, most importantly, pose danger. Training in simulation, on the other hand, would most likely result in poor performance on the real robot. In this letter, we explore the use of Decision Transformers (DT) and their ability to transfer from a simulation-based policy into the real-world. Contrary to RL, we re-frame the problem as sequence modelling and train a DT by supervised learning. The DT is trained off-line on data collected from a far-from-reality simulation through random actions without any prior knowledge on how to throw. Then, the DT is fine-tuned on an handful ($\\sim 5$) of real throws. Results on various objects show accurate throws reaching an error of approximately 4 cm. Also, the DT can extrapolate and accurately throw to goals that are out-of-distribution to the training data. We additionally show that few expert throw samples, and no pre-training in simulation, are sufficient for training an accurate policy.", "venue": "IEEE Robotics and Automation Letters", "year": 2023, "referenceCount": 31, "citationCount": 1, "influentialCitationCount": 0, "isOpenAccess": false, "openAccessPdf": null, "fieldsOfStudy": ["Computer Science"], "s2FieldsOfStudy": [{"category": "Computer Science", "source": "external"}, {"category": "Computer Science", "source": "s2-fos-model"}], "publicationTypes": ["JournalArticle"], "publicationDate": "2023-02-01", "journal": {"volume": "8", "pages": "576-583", "name": "IEEE Robotics and Automation Letters"}, "authors": [{"authorId": "97501516", "name": "M. Monastirsky"}, {"authorId": "2049081755", "name": "Osher Azulay"}, {"authorId": "38111870", "name": "A. Sintov"}]}}
Loading

0 comments on commit 0397761

Please sign in to comment.