コード例 #1
0
ファイル: identifier.go プロジェクト: richardlehane/siegfried
func bulkAdd(m ids, ns string, bids []string, infs map[string]formatInfo, basis string, t core.MatcherType, rel int) ids {
	nids := make(ids, len(m), len(m)+len(bids))
	for _, bid := range bids {
		var has bool
		for i, v := range m {
			if v.ID == bid {
				m[i].Basis = append(m[i].Basis, basis)
				m[i] = applyScore(m[i], infs[bid], t, rel)
				has = true
				break
			}
		}
		if !has {
			md := Identification{
				Namespace: ns,
				ID:        bid,
				Name:      infs[bid].comment,
				Basis:     []string{basis},
				Warning:   "",
				archive:   config.IsArchive(bid),
			}
			nids = append(nids, applyScore(md, infs[bid], t, rel))
		}
	}
	copy(nids, m)
	return nids
}
コード例 #2
0
ファイル: identifier.go プロジェクト: richardlehane/siegfried
func add(m ids, ns string, id string, info formatInfo, basis string, t core.MatcherType, rel int) ids {
	for i, v := range m {
		if v.ID == id {
			m[i].Basis = append(m[i].Basis, basis)
			m[i] = applyScore(m[i], info, t, rel)
			return m
		}
	}
	md := Identification{
		Namespace: ns,
		ID:        id,
		Name:      info.comment,
		Basis:     []string{basis},
		Warning:   "",
		archive:   config.IsArchive(id),
	}
	return append(m, applyScore(md, info, t, rel))
}
コード例 #3
0
ファイル: identifier.go プロジェクト: richardlehane/siegfried
func add(p pids, id string, f string, info formatInfo, basis string, c int) pids {
	for i, v := range p {
		if v.ID == f {
			p[i].confidence += c
			p[i].Basis = append(p[i].Basis, basis)
			return p
		}
	}
	return append(p, Identification{id, f, info.name, info.version, info.mimeType, []string{basis}, "", config.IsArchive(f), c})
}