pub struct SemanticScholar {
pub api_key: String,
}Fields§
§api_key: StringImplementations§
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>
§Description
Get details about an author by their Semantic Scholar author ID.
Available fields for author_fields: Vec<AuthorField>, see: AuthorField.
See for more details: Details about an author
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.paper_id("1741101"); // author_id is passed via paper_id field
query_params.author_fields(vec![
AuthorField::Name,
AuthorField::PaperCount,
AuthorField::CitationCount,
AuthorField::HIndex,
]);
let author = ss.query_author_details(query_params, 5, 10).await.unwrap();
assert!(author.name.is_some());§Description
Search for authors by name.
Available fields for author_fields: Vec<AuthorField>, see: AuthorField.
See for more details: Search for authors by name
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.query_text("Yoshua Bengio");
query_params.author_fields(vec![
AuthorField::Name,
AuthorField::PaperCount,
AuthorField::CitationCount,
]);
let response = ss.search_authors(query_params, 5, 10).await.unwrap();
assert!(!response.data.is_empty());§Description
Get papers by an author.
Available fields for fields: Vec<PaperField>, see: PaperField.
See for more details: Details about an author’s papers
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.paper_id("1741101"); // author_id is passed via paper_id field
query_params.fields(vec![
PaperField::Title,
PaperField::Year,
PaperField::CitationCount,
]);
query_params.limit(10);
let response = ss.query_author_papers(query_params, 5, 10).await.unwrap();
assert!(!response.data.is_empty());§Description
Get authors of a paper.
Available fields for author_fields: Vec<AuthorField>, see: AuthorField.
See for more details: Details about a paper’s authors
§Example
let mut ss = SemanticScholar::new();
let mut query_params = QueryParams::default();
query_params.paper_id("204e3073870fae3d05bcbc2f6a8e263d9b72e776");
query_params.author_fields(vec![
AuthorField::Name,
AuthorField::PaperCount,
AuthorField::CitationCount,
]);
let response = ss.query_paper_authors(query_params, 5, 10).await.unwrap();
assert!(!response.data.is_empty());Trait Implementations§
Source§impl Clone for SemanticScholar
impl Clone for SemanticScholar
Source§fn clone(&self) -> SemanticScholar
fn clone(&self) -> SemanticScholar
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more