Documentation
¶
Overview ¶
Copyright 2015 by Leipzig University Library, http://ub.uni-leipzig.de
by The Finc Authors, http://finc.info
by 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+>
Copyright 2015 by Leipzig University Library, http://ub.uni-leipzig.de
by The Finc Authors, http://finc.info
by 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+>
Package crossref implements crossref related structs and transformations.
API endpoint/documentation: http://api.crossref.org
The two main functions are ToSchema and ToSolrSchema, that convert a crossref document into an intermediate schema or a SOLR schema (finc).
Copyright 2015 by Leipzig University Library, http://ub.uni-leipzig.de
by The Finc Authors, http://finc.info
by 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
- Variables
- func LookupMemberName(id int) (name string, err error)
- func PopulateMemberNameCache(filename string) error
- type Author
- type Crossref
- type DateField
- type DatePart
- type Document
- func (doc *Document) CombinedTitle() string
- func (doc *Document) FullTitle() string
- func (doc *Document) MemberName() (name string, err error)
- func (doc *Document) PageInfo() PageInfo
- func (doc *Document) RecordID() string
- func (doc *Document) ShortTitle() (s string)
- func (doc *Document) ToIntermediateSchema() (*finc.IntermediateSchema, error)
- type IntStringCache
- type Member
- type Message
- type PageInfo
Constants ¶
const (
// Internal bookkeeping.
SourceID = "49"
)
Variables ¶
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:"} // Future, if a publication date lies beyond it, it gets skipped. Future = time.Now().Add(time.Hour * 24 * 365 * 5) )
Functions ¶
func LookupMemberName ¶
LookupMemberName returns the primary name for a member given by its ID. Example URL: http://api.crossref.org/members/56
func PopulateMemberNameCache ¶
PopulateMemberNameCache takes an LDJ filename with one member document per line and populates the cache.
Types ¶
type Author ¶
Author is given by family and given name.
func (*Author) FamilyCleaned ¶
FamilyCleaned returns a mostly clean family name.
func (*Author) GivenCleaned ¶
GivenCleaned returns a mostly clean family name.
type DateField ¶
type DateField struct {
DateParts []DatePart `json:"date-parts"`
Timestamp int64 `json:"timestamp"`
}
DateField contains two representations of one value.
type DatePart ¶
type DatePart []int
DatePart consists of up to three int, representing year, month, day.
type Document ¶
type Document struct {
Authors []Author `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.
func (*Document) CombinedTitle ¶
CombinedTitle returns a longish title.
func (*Document) MemberName ¶
MemberName resolves the primary name of the member.
func (*Document) PageInfo ¶
PageInfo parses a page specfication in a best effort manner into a PageInfo struct.
func (*Document) RecordID ¶
RecordID 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) ShortTitle ¶
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 IntStringCache ¶
IntStringCache for int keys and string values with a thread-safe setter. TODO(miku): move to something more generic
func NewIntStringCache ¶
func NewIntStringCache() IntStringCache
NewIntStringCache creates a new in memory members cache.
func (*IntStringCache) Set ¶
func (c *IntStringCache) Set(k int, v string)
Set sets the string value for an int key, threadsafe.
type Member ¶
type Member struct {
ID int `json:"id"`
PrimaryName string `json:"primary-name"`
Names []string `json:"names"`
Location string `json:"location"`
Prefixes []string `json:"prefixes"`
Tokens []string `json:"tokens"`
}
Member covers a member type message.
func FetchMember ¶
FetchMember makes an API request for a member given by its ID.