func (r *Recorder) Record(m core.MatcherType, res core.Result) bool { switch m { default: return false case core.NameMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), m, rel(r.Place(core.NameMatcher, res.Index()))) return true } else { return false } case core.MIMEMatcher, core.XMLMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), m, 0) return true } else { return false } case core.ByteMatcher: if hit, id := r.Hit(m, res.Index()); hit { if r.satisfied { return true } basis := res.Basis() p, t := r.Place(core.ByteMatcher, res.Index()) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.Name(), id, r.infos[id], basis, m, p-1) return true } else { return false } case core.TextMatcher: if hit, _ := r.Hit(m, res.Index()); hit { if r.satisfied { return true } if len(r.IDs(m)) > 0 { r.ids = bulkAdd(r.ids, r.Name(), r.IDs(m), r.infos, res.Basis(), core.TextMatcher, 0) } return true } else { return false } } }
func (r *Recorder) Record(m core.MatcherType, res core.Result) bool { switch m { default: return false case core.NameMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), extScore) return true } else { return false } case core.MIMEMatcher: if hit, id := r.Hit(m, res.Index()); hit { r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), mimeScore) return true } else { return false } case core.ContainerMatcher: // add zip default if res.Index() < 0 { if r.ZipDefault() { r.cscore += incScore r.ids = add(r.ids, r.Name(), config.ZipPuid(), r.infos[config.ZipPuid()], res.Basis(), r.cscore) } return false } if hit, id := r.Hit(m, res.Index()); hit { r.cscore += incScore basis := res.Basis() p, t := r.Place(core.ContainerMatcher, res.Index()) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.Name(), id, r.infos[id], basis, r.cscore) return true } else { return false } case core.ByteMatcher: if hit, id := r.Hit(m, res.Index()); hit { if r.satisfied { return true } r.cscore += incScore basis := res.Basis() p, t := r.Place(core.ByteMatcher, res.Index()) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.Name(), id, r.infos[id], basis, r.cscore) return true } else { return false } case core.TextMatcher: if hit, id := r.Hit(m, res.Index()); hit { if r.satisfied { return true } r.ids = add(r.ids, r.Name(), id, r.infos[id], res.Basis(), textScore) return true } else { return false } } }
func (r *Recorder) Record(m core.MatcherType, res core.Result) bool { switch m { default: return false case core.ExtensionMatcher: if res.Index() >= r.eStart && res.Index() < r.eStart+len(r.ePuids) { idx := res.Index() - r.eStart r.ids = add(r.ids, r.name, r.ePuids[idx], r.infos[r.ePuids[idx]], res.Basis(), r.cscore) return true } else { return false } case core.ContainerMatcher: // add zip default if res.Index() < 0 { if !r.noPriority { r.cscore *= 2 } r.ids = add(r.ids, r.name, "x-fmt/263", r.infos["x-fmt/263"], res.Basis(), r.cscore) // not great to have this hardcoded return false } if res.Index() >= r.cStart && res.Index() < r.cStart+len(r.cPuids) { idx := res.Index() - r.cStart if !r.noPriority { r.cscore *= 2 } else { r.cscore = 2 } basis := res.Basis() p, t := place(idx, r.cPuids) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.name, r.cPuids[idx], r.infos[r.cPuids[idx]], basis, r.cscore) return true } else { return false } case core.ByteMatcher: if res.Index() >= r.bStart && res.Index() < r.bStart+len(r.bPuids) { idx := res.Index() - r.bStart if !r.noPriority { r.cscore *= 2 } else { r.cscore = 2 } basis := res.Basis() p, t := place(idx, r.bPuids) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.name, r.bPuids[idx], r.infos[r.bPuids[idx]], basis, r.cscore) return true } else { return false } case core.TextMatcher: if res.Index() == r.tStart { r.ids = add(r.ids, r.name, "x-fmt/111", r.infos["x-fmt/111"], res.Basis(), 2) return true } else { return false } } }
func (r *Recorder) Record(m core.MatcherType, res core.Result) bool { switch m { default: return false case core.ExtensionMatcher: if res.Index() >= r.eStart && res.Index() < r.eStart+len(r.ePuids) { idx := res.Index() - r.eStart r.ids = add(r.ids, r.name, r.ePuids[idx], r.infos[r.ePuids[idx]], res.Basis(), extScore) return true } else { return false } case core.MIMEMatcher: if res.Index() >= r.mStart && res.Index() < r.mStart+len(r.mPuids) { idx := res.Index() - r.mStart r.ids = add(r.ids, r.name, r.mPuids[idx], r.infos[r.mPuids[idx]], res.Basis(), mimeScore) return true } else { return false } case core.ContainerMatcher: // add zip default if res.Index() < 0 { if r.zipDefault { r.cscore += incScore r.ids = add(r.ids, r.name, config.ZipPuid(), r.infos[config.ZipPuid()], res.Basis(), r.cscore) } return false } if res.Index() >= r.cStart && res.Index() < r.cStart+len(r.cPuids) { idx := res.Index() - r.cStart r.cscore += incScore basis := res.Basis() p, t := place(idx, r.cPuids) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.name, r.cPuids[idx], r.infos[r.cPuids[idx]], basis, r.cscore) return true } else { return false } case core.ByteMatcher: if res.Index() >= r.bStart && res.Index() < r.bStart+len(r.bPuids) { if r.satisfied { return true } idx := res.Index() - r.bStart r.cscore += incScore basis := res.Basis() p, t := place(idx, r.bPuids) if t > 1 { basis = basis + fmt.Sprintf(" (signature %d/%d)", p, t) } r.ids = add(r.ids, r.name, r.bPuids[idx], r.infos[r.bPuids[idx]], basis, r.cscore) return true } else { return false } case core.TextMatcher: if res.Index() == r.tStart { if r.satisfied { return true } r.ids = add(r.ids, r.name, config.TextPuid(), r.infos[config.TextPuid()], res.Basis(), textScore) return true } else { return false } } }