Skip to main content

Module step_2

Module step_2 

Source
Expand description

§Step 2 - Paper & Author Structs

This tutorial covers the main data structures used in ss-tools.

§Paper Struct

The Paper struct represents a scientific paper from Semantic Scholar. All fields are optional since the API returns only requested fields.

use ss_tools::structs::Paper;

// Paper struct has many optional fields
let paper = Paper::default();
assert!(paper.paper_id.is_none());
assert!(paper.title.is_none());

§Key Paper Fields

FieldTypeDescription
paper_idOption<String>Unique paper ID
titleOption<String>Paper title
abstract_textOption<String>Paper abstract
yearOption<u32>Publication year
citation_countOption<u32>Number of citations
reference_countOption<u32>Number of references
authorsOption<Vec<Author>>List of authors
external_idsOption<ExternalIds>External IDs (ArXiv, DOI, etc.)
open_access_pdfOption<OpenAccessPdf>Open access PDF URL

§ExternalIds Struct

The ExternalIds struct provides access to external identifiers such as ArXiv ID, DOI, DBLP, PubMed, MAG, ACL, and CorpusId.

use ss_tools::structs::ExternalIds;

let ids = ExternalIds::default();
assert!(ids.arxiv.is_none());
assert!(ids.doi.is_none());

§ExternalIds Fields

FieldTypeDescription
arxivOption<String>ArXiv ID (e.g., “1706.03762”)
doiOption<String>DOI (e.g., “10.48550/arXiv.1706.03762”)
dblpOption<String>DBLP ID
pubmedOption<String>PubMed ID
pubmed_centralOption<String>PubMed Central ID
magOption<String>Microsoft Academic Graph ID
aclOption<String>ACL Anthology ID
corpus_idOption<u64>Semantic Scholar Corpus ID

§Author Struct

The Author struct represents an author from Semantic Scholar.

use ss_tools::structs::Author;

let author = Author::default();
assert!(author.author_id.is_none());
assert!(author.name.is_none());

§Key Author Fields

FieldTypeDescription
author_idOption<String>Unique author ID
nameOption<String>Author name
affiliationsOption<Vec<String>>Author affiliations
paper_countOption<u32>Number of papers
citation_countOption<u32>Total citations
hindexOption<u32>H-index

§Field Enums

§PaperField

Use PaperField to specify which paper fields to request.

use ss_tools::structs::PaperField;

let fields = vec![
    PaperField::Title,
    PaperField::Abstract,
    PaperField::Year,
    PaperField::CitationCount,
    PaperField::ExternalIds,
];

§AuthorField

Use AuthorField to specify which author fields to request.

use ss_tools::structs::AuthorField;

let fields = vec![
    AuthorField::Name,
    AuthorField::PaperCount,
    AuthorField::CitationCount,
    AuthorField::HIndex,
];

§Response Structs

§AuthorSearchResponse

Response from searching authors by name.

use ss_tools::structs::AuthorSearchResponse;

// Contains offset, next, total, and data (Vec<Author>)
let response = AuthorSearchResponse::default();
assert!(response.data.is_empty());

§AuthorPapersResponse

Response from querying an author’s papers.

use ss_tools::structs::AuthorPapersResponse;

// Contains offset, next, and data (Vec<Paper>)
let response = AuthorPapersResponse::default();
assert!(response.data.is_empty());

§PaperAuthorsResponse

Response from querying a paper’s authors.

use ss_tools::structs::PaperAuthorsResponse;

// Contains offset, next, and data (Vec<Author>)
let response = PaperAuthorsResponse::default();
assert!(response.data.is_empty());