SemanticScholar

Struct SemanticScholar 

Source
pub struct SemanticScholar {
    pub api_key: String,
}

Fields§

§api_key: String

Implementations§

Source§

impl SemanticScholar

Source

pub fn new() -> Self

Source

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");
Source

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()
);
Source

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()
);
Source

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());
Source

pub async fn query_paper_citations( &mut self, query_params: QueryParams, max_retry_count: u64, wait_time: u64, ) -> Result<ResponsePapers>

Source

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

Source§

fn clone(&self) -> SemanticScholar

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SemanticScholar

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SemanticScholar

Source§

fn default() -> SemanticScholar

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,