Documentation ¶
Overview ¶
Package crossref provides function to convert Crossref metadata to/from the commonmeta metadata format.
Index ¶
- Variables
- func Fetch(str string) (commonmeta.Data, error)
- func FetchAll(number int, member string, _type string, sample bool, hasORCID bool, ...) ([]commonmeta.Data, error)
- func GetMember(memberId string) (string, bool)
- func Load(filename string) (commonmeta.Data, error)
- func LoadAll(filename string) ([]commonmeta.Data, error)
- func QueryURL(number int, member string, _type string, sample bool, hasORCID bool, ...) string
- func Read(content Content) (commonmeta.Data, error)
- func ReadAll(content []Content) ([]commonmeta.Data, error)
- type Content
- type Reader
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CRToCMContainerTranslations = map[string]string{
"book": "Book",
"book-series": "BookSeries",
"database": "DataRepository",
"journal": "Journal",
"proceedings": "Proceedings",
"periodical": "Periodical",
}
CRToCMContainerTranslations maps Crossref container types to Commonmeta container types
var CRToCMMappings = map[string]string{
"book-chapter": "BookChapter",
"book-part": "BookPart",
"book-section": "BookSection",
"book-series": "BookSeries",
"book-set": "BookSet",
"book-track": "BookTrack",
"book": "Book",
"component": "Component",
"database": "Database",
"dataset": "Dataset",
"dissertation": "Dissertation",
"edited-book": "Book",
"grant": "Grant",
"journal-article": "JournalArticle",
"journal-issue": "JournalIssue",
"journal-volume": "JournalVolume",
"journal": "Journal",
"monograph": "Book",
"other": "Other",
"peer-review": "PeerReview",
"posted-content": "Article",
"proceedings-article": "ProceedingsArticle",
"proceedings-series": "ProceedingsSeries",
"proceedings": "Proceedings",
"reference-book": "Book",
"reference-entry": "Entry",
"report-component": "ReportComponent",
"report-series": "ReportSeries",
"report": "Report",
"standard": "Standard",
}
CRToCMMappings maps Crossref types to Commonmeta types source: http://api.crossref.org/types
var CrossrefContainerTypes = map[string]string{
"book-chapter": "book",
"dataset": "database",
"journal-article": "journal",
"journal-issue": "journal",
"monograph": "book-series",
"proceedings-article": "proceedings",
"posted-content": "periodical",
}
CrossrefContainerTypes maps Crossref types to Crossref container types
Functions ¶
func Fetch ¶ added in v0.2.1
func Fetch(str string) (commonmeta.Data, error)
Fetch gets the metadata for a single work from the Crossref API and converts it to the Commonmeta format
func FetchAll ¶ added in v0.2.14
func FetchAll(number int, member string, _type string, sample bool, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) ([]commonmeta.Data, error)
FetchAll gets the metadata for a list of works from the Crossref API and converts it to the Commonmeta format
func GetMember ¶ added in v0.2.1
Get the Crossref member name for a given memberId
Example ¶
package main import ( "github.com/front-matter/commonmeta/crossref" ) func main() { s, _ := crossref.GetMember("340") println(s) }
Output: Public Library of Science (PLoS)
func Load ¶ added in v0.2.1
func Load(filename string) (commonmeta.Data, error)
Load loads the metadata for a single work from a JSON file
func LoadAll ¶ added in v0.2.14
func LoadAll(filename string) ([]commonmeta.Data, error)
LoadAll loads the metadata for a list of works from a JSON file and converts it to the Commonmeta format
func QueryURL ¶ added in v0.2.1
func QueryURL(number int, member string, _type string, sample bool, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) string
QueryURL returns the URL for the Crossref API query
Example ¶
package main import ( "github.com/front-matter/commonmeta/crossref" ) func main() { s := crossref.QueryURL(10, "340", "journal-article", false, false, false, false, false, false, false, false, false) println(s) }
Output: https://api.crossref.org/works?filter=member%3A340%2Ctype%3Ajournal-article&order=desc&rows=10&sort=published
Types ¶
type Content ¶
type Content struct { ID string `json:"id"` Type string `json:"type"` Abstract string `json:"abstract"` Archive []string `json:"archive"` Author []struct { Given string `json:"given"` Family string `json:"family"` Name string `json:"name"` ORCID string `json:"ORCID"` Sequence string `json:"sequence"` Affiliation []struct { ID []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"id"` Name string `json:"name"` } `json:"affiliation"` } `json:"author"` ContainerTitle []string `json:"container-title"` DOI string `json:"doi"` Files []struct{} `json:"files"` Funder []struct { DOI string `json:"DOI"` Name string `json:"name"` Award []string `json:"award"` } `json:"funder"` GroupTitle string `json:"group-title"` Issue string `json:"issue"` Published struct { DateAsParts [][]int `json:"date-parts"` DateTime string `json:"date-time"` } `json:"published"` Issued struct { DateAsParts [][]int `json:"date-parts"` DateTime string `json:"date-time"` } `json:"issued"` Created struct { DateAsParts [][]int `json:"date-parts"` DateTime string `json:"date-time"` } `json:"created"` ISSNType []struct { Value string `json:"value"` Type string `json:"type"` } `json:"issn-type"` ISBNType []struct { Value string `json:"value"` Type string `json:"type"` } `json:"isbn-type"` Language string `json:"language"` License []struct { URL string `json:"URL"` ContentVersion string `json:"content-version"` } `json:"license"` Link []struct { ContentType string `json:"content-type"` URL string `json:"url"` } `json:"link"` OriginalTitle []string `json:"original-title"` Page string `json:"page"` PublishedAt string `json:"published_at"` Publisher string `json:"publisher"` Reference []struct { Key string `json:"key"` DOI string `json:"DOI"` ArticleTitle string `json:"article-title"` Year string `json:"year"` Unstructured string `json:"unstructured"` } `json:"reference"` Relation struct { IsNewVersionOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-new-version-of"` IsPreviousVersionOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-previous-version-of"` IsVersionOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-version-of"` HasVersion []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"has-version"` IsPartOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-part-of"` HasPart []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"has-part"` IsVariantFormOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-variant-form-of"` IsOriginalFormOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-original-form-of"` IsIdenticalTo []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-identical-to"` IsTranslationOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-translation-of"` IsReviewedBy []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-reviewed-by"` Reviews []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"reviews"` HasReview []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"has-review"` IsPreprintOf []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-preprint-of"` HasPreprint []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"has-preprint"` IsSupplementTo []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-supplement-to"` IsSupplementedBy []struct { ID string `json:"id"` IDType string `json:"id-type"` } `json:"is-supplemented-by"` } `json:"relation"` Resource struct { Primary struct { ContentType string `json:"content_type"` URL string `json:"url"` } `json:"primary"` } `json:"resource"` Subject []string `json:"subject"` Subtitle []string `json:"subtitle"` Title []string `json:"title"` URL string `json:"url"` Version string `json:"version"` Volume string `json:"volume"` }
Content is the struct for the message in tge JSON response from the Crossref API
func GetAll ¶ added in v0.2.14
func GetAll(number int, member string, _type string, sample bool, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) ([]Content, error)
GetAll gets the metadata for a list of works from the Crossref API