Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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))
}
Ejemplo n.º 3
0
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})
}