diff options
-rw-r--r-- | skate/cmd/skate-biblioref-from-wikipedia/main.go | 12 | ||||
-rw-r--r-- | skate/schema.go | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/skate/cmd/skate-biblioref-from-wikipedia/main.go b/skate/cmd/skate-biblioref-from-wikipedia/main.go index 61b590e..86fba1a 100644 --- a/skate/cmd/skate-biblioref-from-wikipedia/main.go +++ b/skate/cmd/skate-biblioref-from-wikipedia/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "os" "runtime" @@ -25,12 +26,13 @@ func main() { if err := json.Unmarshal(p, &w); err != nil { return nil, err } - b, err := json.Marshal(w.ParseIDList()) - if err != nil { - return nil, err + idl := w.ParseIDList() + if idl.DOI == "" { + return nil, nil } - b = append(b, bytesNewline...) - return b, nil + s := fmt.Sprintf("%s\t%s\n", idl.DOI, string(p)) + return []byte(s), nil + }) pp.NumWorkers = *numWorkers pp.BatchSize = *batchSize diff --git a/skate/schema.go b/skate/schema.go index 4a33be3..acb2601 100644 --- a/skate/schema.go +++ b/skate/schema.go @@ -275,6 +275,11 @@ type IDList struct { OL string `json:"ol,omitempty"` } +func (l *IDList) IsZero() bool { + return l.ISBN == "" && l.DOI == "" && l.PMID == "" && l.ISSN == "" && + l.JSTOR == "" && l.PMC == "" && l.ARXIV == "" && l.OL == "" +} + func (c *MinimalCitations) ParseIDList() (result IDList) { if len(c.IDList) < 3 { return result |