package fuzzy // DualIndex holds WordIndex instances for two language word lists. // Built in the transdb package (which knows the lattice); queried here. type DualIndex struct { A *WordIndex // first language (e.g. EN) B *WordIndex // second language (e.g. JA) } // NewDualIndex wraps two pre-built WordIndex instances. func NewDualIndex(a, b *WordIndex) *DualIndex { return &DualIndex{A: a, B: b} } // SuggestA returns fuzzy suggestions from the A index (max maxResults). func (idx *DualIndex) SuggestA(query string, maxDist, maxResults int) []Match { if idx == nil || idx.A == nil { return nil } m := idx.A.Search(query, maxDist) if len(m) > maxResults { m = m[:maxResults] } return m } // SuggestB returns fuzzy suggestions from the B index. func (idx *DualIndex) SuggestB(query string, maxDist, maxResults int) []Match { if idx == nil || idx.B == nil { return nil } m := idx.B.Search(query, maxDist) if len(m) > maxResults { m = m[:maxResults] } return m }