Skip to content

Commit

Permalink
feat: add min_citation_count filtering option to paper search
Browse files Browse the repository at this point in the history
Resolves: #63
  • Loading branch information
danielnsilva committed Dec 10, 2023
1 parent ed4cf6f commit ab1cc67
Show file tree
Hide file tree
Showing 5 changed files with 4,420 additions and 0 deletions.
6 changes: 6 additions & 0 deletions semanticscholar/AsyncSemanticScholar.py
Expand Up @@ -309,6 +309,7 @@ async def search_paper(
fields_of_study: list = None,
fields: list = None,
publication_date_or_year: str = None,
min_citation_count: int = None,
limit: int = 100
) -> PaginatedResults:
'''Search for papers by keyword
Expand All @@ -331,6 +332,8 @@ async def search_paper(
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 \
with at least the given number of citations.
:param int limit: (optional) maximum number of results to return \
(must be <= 100).
:returns: query results.
Expand Down Expand Up @@ -374,6 +377,9 @@ async def search_paper(
else:
query += f'&publicationDateOrYear={publication_date_or_year}'

if min_citation_count:
query += f'&minCitationCount={min_citation_count}'

results = await PaginatedResults.create(
self._requester,
Paper,
Expand Down
4 changes: 4 additions & 0 deletions semanticscholar/SemanticScholar.py
Expand Up @@ -258,6 +258,7 @@ def search_paper(
fields_of_study: list = None,
fields: list = None,
publication_date_or_year: str = None,
min_citation_count: int = None,
limit: int = 100
) -> PaginatedResults:
'''Search for papers by keyword
Expand All @@ -280,6 +281,8 @@ def search_paper(
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 \
with at least the given number of citations.
:param int limit: (optional) maximum number of results to return \
(must be <= 100).
:returns: query results.
Expand All @@ -297,6 +300,7 @@ def search_paper(
fields_of_study=fields_of_study,
fields=fields,
publication_date_or_year=publication_date_or_year,
min_citation_count=min_citation_count,
limit=limit
)
)
Expand Down

0 comments on commit ab1cc67

Please sign in to comment.