pub struct SemanticScholar {
pub api_key: String,
}
Fields§
§api_key: String
Implementations§
Source§impl SemanticScholar
impl SemanticScholar
pub fn new() -> Self
Sourcepub async fn bulk_query_by_ids(
&mut self,
paper_ids: Vec<&str>,
fields: Vec<PaperField>,
max_retry_count: u64,
wait_time: u64,
) -> Result<Vec<Paper>>
pub async fn bulk_query_by_ids( &mut self, paper_ids: Vec<&str>, fields: Vec<PaperField>, max_retry_count: u64, wait_time: u64, ) -> Result<Vec<Paper>>
§Description
Bulk retrieval of basic paper data without search relevance.
Available fields for fields: Vec<PaperField>
, see: PaperField
.
See for more details: Paper bulk search
§Example
let paper_ids = vec![
"5c5751d45e298cea054f32b392c12c61027d2fe7",
"649def34f8be52c8b66281af98ae884c09aef38b",
"ARXIV:2106.15928",
];
let fields = vec![
PaperField::Title,
PaperField::CitationCount,
];
let max_retry_count = 5;
let wait_time = 10;
let mut ss = SemanticScholar::new();
let papers = ss.bulk_query_by_ids(paper_ids, fields, max_retry_count, wait_time).await.unwrap();
assert_eq!(papers.len(), 3);
let paper = &papers[0].clone();
assert_eq!(paper.title.clone().unwrap(), "S2ORC: The Semantic Scholar Open Research Corpus");
Sourcepub async fn query_papers_by_title(
&mut self,
query_params: QueryParams,
max_retry_count: u64,
wait_time: u64,
) -> Result<Vec<Paper>>
pub async fn query_papers_by_title( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<Vec<Paper>>
§Description
Search for papers related to the given title.
Make sure to provide the query_text
in the query_params
.
For details of ‘query_params’, see: QueryParams
.
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.query_text("attention is all you need");
let max_retry_count = 5;
let wait_time = 10;
let papers = ss.query_papers_by_title(query_params, max_retry_count, wait_time).await.unwrap();
assert!(papers.len() > 1);
let paper = papers.first().unwrap();
assert_eq!(paper.paper_id.clone().unwrap(), "204e3073870fae3d05bcbc2f6a8e263d9b72e776");
assert_eq!(
paper.title.clone().unwrap().to_lowercase(),
"attention is all you need".to_string()
);
Sourcepub async fn query_a_paper_by_title(
&mut self,
query_params: QueryParams,
max_retry_count: u64,
wait_time: u64,
) -> Result<Paper>
pub async fn query_a_paper_by_title( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<Paper>
§Description
Retrieve a single paper based on closest match to the title.
For details of ‘query_params’, see: QueryParams
.
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.query_text("attention is all you need");
let max_retry_count = 5;
let wait_time = 10;
let paper = ss
.query_a_paper_by_title(query_params, max_retry_count, wait_time)
.await
.unwrap();
assert_eq!(paper.paper_id.clone().unwrap(), "204e3073870fae3d05bcbc2f6a8e263d9b72e776");
assert_eq!(
paper.title.clone().unwrap().to_lowercase(),
"attention is all you need".to_string()
);
Sourcepub async fn query_paper_details(
&mut self,
query_params: QueryParams,
max_retry_count: u64,
wait_time: u64,
) -> Result<Paper>
pub async fn query_paper_details( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<Paper>
§Description
Retrieve details of a single paper based on the paper id.
Make sure to provide the paper_id
in the query_params
.
For details of ‘query_params’, see: QueryParams
.
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
query_params.fields(vec![
PaperField::Title,
PaperField::Abstract,
PaperField::CitationCount,
PaperField::ReferenceCount,
PaperField::Year,
]);
let paper_details = ss.query_paper_details(query_params, 5, 10).await.unwrap();
let title = paper_details.title.clone().unwrap();
assert_eq!(title.to_lowercase(), "attention is all you need".to_string());
pub async fn query_paper_citations( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<ResponsePapers>
pub async fn query_paper_references( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<ResponsePapers>
Trait Implementations§
Source§impl Clone for SemanticScholar
impl Clone for SemanticScholar
Source§fn clone(&self) -> SemanticScholar
fn clone(&self) -> SemanticScholar
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SemanticScholar
impl Debug for SemanticScholar
Source§impl Default for SemanticScholar
impl Default for SemanticScholar
Source§fn default() -> SemanticScholar
fn default() -> SemanticScholar
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for SemanticScholar
impl RefUnwindSafe for SemanticScholar
impl Send for SemanticScholar
impl Sync for SemanticScholar
impl Unpin for SemanticScholar
impl UnwindSafe for SemanticScholar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more