diff options
Diffstat (limited to 'skate/schema.go')
-rw-r--r-- | skate/schema.go | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/skate/schema.go b/skate/schema.go index b4d8242..83ceea3 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -212,7 +212,7 @@ type BiblioRef struct { SourceWikipediaArticle string `json:"source_wikipedia_article,omitempty"` SourceReleaseStage string `json:"source_release_stage,omitempty"` SourceYear string `json:"source_year,omitempty"` - RefIndex int64 `json:"ref_index,omitempty"` + RefIndex int64 `json:"ref_index,omitempty"` // 1-based RefKey string `json:"ref_key,omitempty"` RefLocator string `json:"ref_locator,omitempty"` TargetReleaseIdent string `json:"target_release_ident,omitempty"` @@ -227,23 +227,24 @@ type BiblioRef struct { TargetCSL string `json:"target_csl,omitempty"` } -// ClusterResult, a list of match candidates. This is typically serialized as a +// ReleaseCluster, a list of match candidates. This is typically serialized as a // single JSON line. -type ClusterResult struct { +type ReleaseCluster struct { Key string `json:"k"` Values []*Release `json:"v"` } -// NonRef returns the first non-reference release found in a cluster, or an +// OneNonRef returns the first non-reference release found in a cluster, or an // error, if none has been found. This depends on converted references using -// the status "ref" in extra. -func (cr *ClusterResult) OneNonRef() (*Release, error) { - for _, re := range cr.Values { +// the status "ref" in extra. We use this in mixed clusters (catalog entries +// and references converted into releases). +func (rc *ReleaseCluster) OneNonRef() (*Release, error) { + for _, re := range rc.Values { if re.Extra.Skate.Status != "ref" { return re, nil } } - return nil, fmt.Errorf("no reference/release found") + return nil, fmt.Errorf("no reference/release found for cluster key: %v", rc.Key) } // MinimalCitations variant from archive.org/details/wikipedia_citations_2020-07-14. @@ -268,11 +269,12 @@ type IDList struct { // IsZero returns true, if none of the identifiers is defined. func (l *IDList) IsZero() bool { - return l.ISBN == "" && l.DOI == "" && l.PMID == "" && l.ISSN == "" && - l.JSTOR == "" && l.PMC == "" && l.ARXIV == "" && l.OL == "" + return *l == IDList{} } -// ParseIDList parses out the identifiers from a citation document. +// ParseIDList parses out the identifiers from a citation document, the IDList +// values look something like this: "{BIBCODE=1992ApJ...399L..31C, +// DOI=10.1086/186599}". func (c *MinimalCitations) ParseIDList() (result IDList) { if len(c.IDList) < 3 { return result |