本文整理匯總了Golang中github.com/miku/span/finc.IntermediateSchema.Labels方法的典型用法代碼示例。如果您正苦於以下問題:Golang IntermediateSchema.Labels方法的具體用法?Golang IntermediateSchema.Labels怎麽用?Golang IntermediateSchema.Labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/miku/span/finc.IntermediateSchema
的用法示例。
在下文中一共展示了IntermediateSchema.Labels方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Tag
// Tag takes an intermediate schema and returns a labeled version of that
// schema.
func (t *Tagger) Tag(is finc.IntermediateSchema) finc.IntermediateSchema {
var tags []string
for tag, filter := range t.filtermap {
if filter.Apply(is) {
tags = append(tags, tag)
}
}
is.Labels = tags
return is
}
示例2: main
//.........這裏部分代碼省略.........
switch *format {
case "kbart":
hr = kbart.NewReader(hfile)
case "ovid":
hr = ovid.NewReader(hfile)
case "google":
hr = google.NewReader(hfile)
default:
log.Fatalf("invalid holding file format: %s", *format)
}
entries, err := hr.ReadAll()
if err != nil {
switch err.(type) {
case holdings.ParseError:
if *ignoreUnmarshalErrors {
log.Println(err)
} else {
log.Fatal(err)
}
default:
log.Fatal(err)
}
}
for {
b, err := r.ReadBytes('\n')
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
var is = new(finc.IntermediateSchema)
if err := json.Unmarshal(b, is); err != nil {
log.Fatal(err)
}
signature := holdings.Signature{
Date: is.Date.Format("2006-01-02"),
Volume: is.Volume,
Issue: is.Issue,
}
// validate record, if at least one license allows this item
var valid bool
var messages = container.NewStringSet()
LOOP:
for _, issn := range append(is.ISSN, is.EISSN...) {
licenses := entries.Licenses(issn)
if len(licenses) == 0 {
messages.Add(fmt.Sprintf("ISSN not in holdings"))
}
if len(licenses) == 0 && *permissiveMode {
messages.Add("PERMISSIVE_OK")
valid = true
break LOOP
}
for _, license := range licenses {
if err := license.Covers(signature); err != nil {
messages.Add(err.Error())
} else {
if err := license.TimeRestricted(is.Date); err != nil {
messages.Add(err.Error())
} else {
messages.Add("OK")
valid = true
break LOOP
}
}
}
}
if len(is.ISSN) == 0 && len(is.EISSN) == 0 {
messages.Add("Record has no ISSN")
}
if len(is.ISSN) == 0 && len(is.EISSN) == 0 && *permissiveMode {
messages.Add("PERMISSIVE_OK")
valid = true
}
if valid {
is.Labels = []string{*label}
}
bs, err := json.Marshal(is)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(bs))
// values := messages.Values()
// sort.Strings(values)
// fmt.Printf("%s\t%v\t%v\n", is.RecordID, valid, strings.Join(values, ", "))
}
}