protected virtual IEnumerable<int> GetCandidates(QueryParser qparser, IList<IList<int>> posting_lists, IIntersection<int> ialg) { if (posting_lists.Count == 0) { return new int[0]; } else if (posting_lists.Count == 1) { return posting_lists [0]; } else { return ialg.Intersection (posting_lists); } }
protected virtual IList<IList<int>> GetPostingLists(QueryParser qparser) { var posting_lists = new List<IList<int>> (); for (int i = 0; i < qparser.Query.Count; ++i) { int symbol; if (qparser.Query[i] != null && this.RankVoc (qparser.Query [i], out symbol)) { var rs = this.Seq.Unravel (symbol); var L = new SortedListRSCache (rs, -i); posting_lists.Add (L); } } return posting_lists; }
public virtual IList<int> SearchPhrase(string query, IIntersection<int> ialg, Action<QueryParser> modify_query = null) { var qparser = new QueryParser (this.InputTokenizer); qparser.Parse (query); if (null != modify_query) { modify_query (qparser); } var posting = this.GetPostingLists (qparser); var _r = this.GetCandidates (qparser, posting, ialg); var _s = _r as IList<int>; if (_s == null) { return new List<int> (_r); } return _s; }