crossref

package
v0.1.205 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2017 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Copyright 2015 by Leipzig University Library, http://ub.uni-leipzig.de
                  The Finc Authors, http://finc.info
                  Martin Czygan, <martin.czygan@uni-leipzig.de>

This file is part of some open source application.

Some open source application is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Some open source application is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>.

@license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>

Index

Constants

View Source
const (
	// Internal bookkeeping.
	SourceID = "49"
)

Variables

View Source
var (
	DefaultFormat = "ElectronicArticle"

	// Load assets
	Formats  = assetutil.MustLoadStringMap("assets/crossref/formats.json")
	Genres   = assetutil.MustLoadStringMap("assets/crossref/genres.json")
	RefTypes = assetutil.MustLoadStringMap("assets/crossref/reftypes.json")

	// AuthorReplacer is a special cleaner for author names.
	AuthorReplacer = strings.NewReplacer("#", "", "--", "", "*", "", "|", "", "&NA;", "", "\u0026NA;", "", "\u0026", "")

	// ArticleTitleBlocker will trigger skips, if article title matches exactly.
	ArticleTitleBlocker = []string{"Titelei", "Front Matter", "Advertisement", "Advertisement:"}

	// ArticleTitleCleanerPatterns removes matching parts.
	ArticleTitleCleanerPatterns = []*regexp.Regexp{

		regexp.MustCompile(`[?]{6,}`),
	}

	// Future ends soon.
	Future = time.Now().Add(time.Hour * 24 * 365 * 5)
)

Functions

This section is empty.

Types

type BulkResponse

type BulkResponse struct {
	Status         string `json:"status"`
	MessageType    string `json:"message-type"`
	MessageVersion string `json:"message-version"`
	Message        struct {
		NextCursor   string     `json:"next-cursor"`
		TotalResults int        `json:"total-results"`
		Items        []Document `json:"items"`
	} `json:"message"`
}

BulkResponse for a bulk request containing multiple items.

type DateField

type DateField struct {
	DateParts []DatePart `json:"date-parts"`
	Timestamp int64      `json:"timestamp"`
}

DateField contains two representations of one value.

func (*DateField) Date

func (d *DateField) Date() (t time.Time, err error)

Date returns a time.Date in a best effort manner. Date parts seem to be always present in the source document, while timestamp is only present if dateparts consist of all three: year, month and day. It is an error, if no valid date can be extracted.

type DatePart

type DatePart []int

DatePart consists of up to three int, representing year, month, day.

type Document

type Document struct {
	Author []struct {
		Family string `json:"family"`
		Given  string `json:"given"`
	} `json:"author"`
	ContainerTitle []string  `json:"container-title"`
	Deposited      DateField `json:"deposited"`
	DOI            string    `json:"DOI"`
	Indexed        DateField `json:"indexed"`
	ISSN           []string  `json:"ISSN"`
	Issue          string    `json:"issue"`
	Issued         DateField `json:"issued"`
	Member         string    `json:"member"`
	Page           string    `json:"page"`
	Prefix         string    `json:"prefix"`
	Publisher      string    `json:"publisher"`
	ReferenceCount int       `json:"reference-count"`
	Score          float64   `json:"score"`
	Source         string    `json:"source"`
	Subjects       []string  `json:"subject"`
	Subtitle       []string  `json:"subtitle"`
	Title          []string  `json:"title"`
	Type           string    `json:"type"`
	URL            string    `json:"URL"`
	Volume         string    `json:"volume"`
}

Document is a example 'works' API response - message part only.

func (*Document) Authors

func (doc *Document) Authors() (authors []finc.Author)

func (*Document) CombinedTitle

func (doc *Document) CombinedTitle() string

CombinedTitle returns a longish title.

func (*Document) ID

func (doc *Document) ID() string

ID is of the form <kind>-<source-id>-<id-base64-unpadded> We simple map any primary key of the source (preferably a URL) to a safer alphabet. Since the base64 part is not meant to be decoded we drop the padding. It is simple enough to recover the original value.

func (*Document) PageInfo

func (doc *Document) PageInfo() PageInfo

PageInfo parses a page specfication in a best effort manner into a PageInfo struct.

func (*Document) ShortTitle

func (doc *Document) ShortTitle() (s string)

ShortTitle returns the first main title only.

func (*Document) ToIntermediateSchema

func (doc *Document) ToIntermediateSchema() (*finc.IntermediateSchema, error)

ToIntermediateSchema converts a crossref document into IS.

type PageInfo

type PageInfo struct {
	RawMessage string
	StartPage  int
	EndPage    int
}

PageInfo holds various page related data.

func (*PageInfo) PageCount

func (pi *PageInfo) PageCount() int

PageCount returns the number of pages, or zero if this cannot be determined.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL