コード例 #1
0
ファイル: makeedges.go プロジェクト: pbnjay/gomarc
// most of the code in here is because NAL's QC sucks...
// sometimes annotations end with a '.'...
// sometimes annotations are duplicated...
func edgesFromRecord(r *gomarc.Reader) (ret []string) {
	agricolaId, valid := r.GetField(primaryId[:3], primaryId[3:])
	if !valid {
		return nil
	}

	nodupes := make(map[string]bool)
	for _, sub := range secondaryIds {
		flds, exists := r.GetFields(sub[:3], sub[3:])
		if !exists {
			continue
		}
		for _, fld := range flds {
			if strings.HasSuffix(fld, ".") {
				if strings.HasSuffix(fld, "etc.") {
					// skip
				} else if fld[len(fld)-2] == ')' || fld[len(fld)-3] != '.' { // acronym? "U.S."
					fld = fld[:len(fld)-1]
				}
			}
			if !nodupes[fld] {
				ret = append(ret, agricolaId+"\t"+fld)
				nodupes[fld] = true
			}
		}
	}
	return ret
}