Skip to content

Commit

Permalink
docs(docstrings): remove backslashes to fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnsilva committed Dec 1, 2024
1 parent 085d990 commit 3ef890b
Show file tree
Hide file tree
Showing 3 changed files with 170 additions and 145 deletions.
7 changes: 4 additions & 3 deletions semanticscholar/ApiRequester.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class ApiRequester:

def __init__(self, timeout, retry: bool = True) -> None:
'''
:param float timeout: an exception is raised \
if the server has not issued a response for timeout seconds.
:param float timeout: an exception is raised
if the server has not issued a response for timeout seconds.
:param bool retry: enable retry mode.
'''
self.timeout = timeout
Expand Down Expand Up @@ -76,7 +76,8 @@ async def get_data_async(
headers: dict,
payload: dict = None
) -> Union[dict, List[dict]]:
'''Get data from Semantic Scholar API
'''
Get data from Semantic Scholar API
:param str url: absolute URL to API endpoint.
:param str parameters: the parameters to add in the URL.
Expand Down
154 changes: 83 additions & 71 deletions semanticscholar/AsyncSemanticScholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def __init__(
retry: bool = True,
) -> None:
'''
:param float timeout: (optional) an exception is raised\
if the server has not issued a response for timeout seconds.
:param float timeout: (optional) an exception is raised
if the server has not issued a response for timeout seconds.
:param str api_key: (optional) private API key.
:param str api_url: (optional) custom API url.
:param bool debug: (optional) enable debug mode.
Expand Down Expand Up @@ -124,13 +124,14 @@ async def get_paper(
paper_id: str,
fields: list = None
) -> Paper:
'''Paper lookup
'''
Paper lookup
:calls: `GET /graph/v1/paper/{paper_id} \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_paper>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL, \
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand Down Expand Up @@ -165,13 +166,14 @@ async def get_papers(
fields: list = None,
return_not_found: bool = False
) -> Union[List[Paper], Tuple[List[Paper], List[str]]]:
'''Get details for multiple papers at once
'''
Get details for multiple papers at once
:calls: `POST /graph/v1/paper/batch \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/post_graph_get_papers>`_
:param str paper_ids: list of IDs (must be <= 500) - S2PaperId,\
:param str paper_ids: list of IDs (must be <= 500) - S2PaperId,
CorpusId, DOI, ArXivId, MAG, ACL, PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -181,13 +183,13 @@ async def get_papers(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param bool return_not_found: (optional) flag to include not found IDs\
in the return, except for IDs in URL:<url> format.
:param bool return_not_found: (optional) flag to include not found IDs
in the return, except for IDs in URL:<url> format.
:returns: papers data, and optionally list of IDs not found.
:rtype: :class:`List` of :class:`semanticscholar.Paper.Paper`\
or :class:`Tuple` [:class:`List` of\
:class:`semanticscholar.Paper.Paper`,\
:class:`List` of :class:`str`]
:rtype: :class:`List` of :class:`semanticscholar.Paper.Paper`
or :class:`Tuple` [:class:`List` of
:class:`semanticscholar.Paper.Paper`,
:class:`List` of :class:`str`]
:raises: BadQueryParametersException: if no paper was found.
'''

Expand Down Expand Up @@ -251,13 +253,14 @@ async def get_paper_authors(
fields: list = None,
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's authors
'''
Get details about a paper's authors
:calls: `POST /graph/v1/paper/{paper_id}/authors \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_paper_authors>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -267,7 +270,7 @@ async def get_paper_authors(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
:param int limit: (optional) maximum number of results to return
(must be <= 1000).
'''

Expand Down Expand Up @@ -298,13 +301,14 @@ async def get_paper_citations(
fields: list = None,
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's citations
'''
Get details about a paper's citations
:calls: `POST /graph/v1/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,\
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -314,7 +318,7 @@ async def get_paper_citations(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
:param int limit: (optional) maximum number of results to return
(must be <= 1000).
'''

Expand Down Expand Up @@ -344,13 +348,14 @@ async def get_paper_references(
fields: list = None,
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's references
'''
Get details about a paper's references
:calls: `POST /graph/v1/paper/{paper_id}/references \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_paper_references>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -360,7 +365,7 @@ async def get_paper_references(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
:param int limit: (optional) maximum number of results to return
(must be <= 1000).
'''

Expand Down Expand Up @@ -400,50 +405,51 @@ async def search_paper(
sort: str = None,
match_title: bool = False
) -> Union[PaginatedResults, Paper]:
'''Search for papers by keyword. Performs a search query based on the \
S2 search relevance algorithm, or a bulk retrieval of basic paper \
data without search relevance (if bulk=True). Paper relevance \
search is the default behavior and returns up to 1,000 results. \
Bulk retrieval instead returns up to 10,000,000 results (1,000 \
in each page).
'''
Search for papers by keyword. Performs a search query based on the
S2 search relevance algorithm, or a bulk retrieval of basic paper
data without search relevance (if bulk=True). Paper relevance
search is the default behavior and returns up to 1,000 results.
Bulk retrieval instead returns up to 10,000,000 results (1,000
in each page).
:calls: `GET /graph/v1/paper/search \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_paper_relevance_search>`_
<https://api.semanticscholar.org/api-docs/graph#tag/\
Paper-Data/operation/get_graph_paper_relevance_search>`_
:calls: `GET /graph/v1/paper/search/bulk \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_paper_bulk_search>`_
<https://api.semanticscholar.org/api-docs/graph#tag/\
Paper-Data/operation/get_graph_paper_bulk_search>`_
:param str query: plain-text search query string.
:param str year: (optional) restrict results to the given range of \
:param str year: (optional) restrict results to the given range of
publication year.
:param list publication_type: (optional) restrict results to the given \
:param list publication_type: (optional) restrict results to the given
publication type list.
:param bool open_access_pdf: (optional) restrict results to papers \
:param bool open_access_pdf: (optional) restrict results to papers
with public PDFs.
:param list venue: (optional) restrict results to the given venue list.
:param list fields_of_study: (optional) restrict results to given \
:param list fields_of_study: (optional) restrict results to given
field-of-study list, using the s2FieldsOfStudy paper field.
:param list fields: (optional) list of the fields to be returned.
:param str publication_date_or_year: (optional) restrict results to \
the given range of publication date in the format \
<start_date>:<end_date>, where dates are in the format \
:param str publication_date_or_year: (optional) restrict results to
the given range of publication date in the format
<start_date>:<end_date>, where dates are in the format
YYYY-MM-DD, YYYY-MM, or YYYY.
:param int min_citation_count: (optional) restrict results to papers \
:param int min_citation_count: (optional) restrict results to papers
with at least the given number of citations.
:param int limit: (optional) maximum number of results to return \
:param int limit: (optional) maximum number of results to return
(must be <= 100).
:param bool bulk: (optional) bulk retrieval of basic paper data \
without search relevance (ignores the limit parameter if True \
:param bool bulk: (optional) bulk retrieval of basic paper data
without search relevance (ignores the limit parameter if True
and returns up to 1,000 results in each page).
:param str sort: (optional) sorts results (only if bulk=True) using \
<field>:<order> format, where "field" is either paperId, \
publicationDate, or citationCount, and "order" is asc \
:param str sort: (optional) sorts results (only if bulk=True) using
<field>:<order> format, where "field" is either paperId,
publicationDate, or citationCount, and "order" is asc
(ascending) or desc (descending).
:param bool match_title: (optional) retrieve a single paper whose \
:param bool match_title: (optional) retrieve a single paper whose
title best matches the given query.
:returns: query results.
:rtype: :class:`semanticscholar.PaginatedResults.PaginatedResults` or \
:rtype: :class:`semanticscholar.PaginatedResults.PaginatedResults` or
:class:`semanticscholar.Paper.Paper`
'''

Expand Down Expand Up @@ -521,7 +527,8 @@ async def get_author(
author_id: str,
fields: list = None
) -> Author:
'''Author lookup
'''
Author lookup
:calls: `GET /graph/v1/author/{author_id} \
<https://api.semanticscholar.org/api-docs/graph#tag/Author-Data\
Expand Down Expand Up @@ -553,18 +560,19 @@ async def get_authors(
fields: list = None,
return_not_found: bool = False
) -> Union[List[Author], Tuple[List[Author], List[str]]]:
'''Get details for multiple authors at once
'''
Get details for multiple authors at once
:calls: `POST /graph/v1/author/batch \
<https://api.semanticscholar.org/api-docs/graph#tag/Author-Data\
/operation/get_graph_get_author>`_
:param str author_ids: list of S2AuthorId (must be <= 1000).
:returns: author data, and optionally list of IDs not found.
:rtype: :class:`List` of :class:`semanticscholar.Author.Author`\
or :class:`Tuple` [:class:`List` of\
:class:`semanticscholar.Author.Author`,\
:class:`List` of :class:`str`]
:rtype: :class:`List` of :class:`semanticscholar.Author.Author`
or :class:`Tuple` [:class:`List` of
:class:`semanticscholar.Author.Author`,
:class:`List` of :class:`str`]
:raises: BadQueryParametersException: if no author was found.
'''

Expand Down Expand Up @@ -601,13 +609,14 @@ async def get_author_papers(
fields: list = None,
limit: int = 100
) -> PaginatedResults:
'''Get details about a author's papers
'''
Get details about a author's papers
:calls: `POST /graph/v1/paper/{author_id}/papers \
<https://api.semanticscholar.org/api-docs/graph#tag/Paper-Data\
/operation/get_graph_get_author_papers>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -617,7 +626,7 @@ async def get_author_papers(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return\
:param int limit: (optional) maximum number of results to return
(must be <= 1000).
'''

Expand Down Expand Up @@ -647,15 +656,16 @@ async def search_author(
fields: list = None,
limit: int = 100
) -> PaginatedResults:
'''Search for authors by name
'''
Search for authors by name
:calls: `GET /graph/v1/author/search \
<https://api.semanticscholar.org/api-docs/graph#tag/Author-Data\
/operation/get_graph_get_author_search>`_
:param str query: plain-text search query string.
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of results to return \
:param int limit: (optional) maximum number of results to return
(must be <= 1000).
:returns: query results.
:rtype: :class:`semanticscholar.PaginatedResults.PaginatedResults`
Expand Down Expand Up @@ -691,13 +701,14 @@ async def get_recommended_papers(
limit: int = 100,
pool_from: Literal["recent", "all-cs"] = "recent"
) -> List[Paper]:
'''Get recommended papers for a single positive example.
'''
Get recommended papers for a single positive example.
:calls: `GET /recommendations/v1/papers/forpaper/{paper_id} \
<https://api.semanticscholar.org/api-docs/recommendations#\
tag/Paper-Recommendations/operation/get_papers_for_paper>`_
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,\
:param str paper_id: S2PaperId, CorpusId, DOI, ArXivId, MAG, ACL,
PMID, PMCID, or URL from:
- semanticscholar.org
Expand All @@ -707,10 +718,10 @@ async def get_recommended_papers(
- biorxiv.org
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of recommendations to \
return (must be <= 500).
:param str pool_from: (optional) which pool of papers to recommend \
from. Must be either "recent" or "all-cs".
:param int limit: (optional) maximum number of recommendations to
return (must be <= 500).
:param str pool_from: (optional) which pool of papers to recommend
from. Must be either "recent" or "all-cs".
:returns: list of recommendations.
:rtype: :class:`List` of :class:`semanticscholar.Paper.Paper`
'''
Expand Down Expand Up @@ -744,19 +755,20 @@ async def get_recommended_papers_from_lists(
fields: list = None,
limit: int = 100
) -> List[Paper]:
'''Get recommended papers for lists of positive and negative examples.
'''
Get recommended papers for lists of positive and negative examples.
:calls: `POST /recommendations/v1/papers/ \
<https://api.semanticscholar.org/api-docs/recommendations#\
tag/Paper-Recommendations/operation/post_papers>`_
:param list positive_paper_ids: list of paper IDs \
that the returned papers should be related to.
:param list negative_paper_ids: (optional) list of paper IDs \
that the returned papers should not be related to.
:param list positive_paper_ids: list of paper IDs
that the returned papers should be related to.
:param list negative_paper_ids: (optional) list of paper IDs
that the returned papers should not be related to.
:param list fields: (optional) list of the fields to be returned.
:param int limit: (optional) maximum number of recommendations to \
return (must be <= 500).
:param int limit: (optional) maximum number of recommendations to
return (must be <= 500).
:returns: list of recommendations.
:rtype: :class:`List` of :class:`semanticscholar.Paper.Paper`
'''
Expand Down
Loading

0 comments on commit 3ef890b

Please sign in to comment.