static private SearchTermResponse AssembleSearchTermResponse(Query query) { StringBuilder sb = new StringBuilder(); SearchTermResponse search_term_response; search_term_response = new SearchTermResponse(); foreach (QueryPart part in query.Parts) { AddSearchTermInfo(part, search_term_response, sb); } return(search_term_response); }
static private SearchTermResponse AssembleSearchTermResponse (Query query) { StringBuilder sb = new StringBuilder (); SearchTermResponse search_term_response; search_term_response = new SearchTermResponse (); foreach (QueryPart part in query.Parts) AddSearchTermInfo (part, search_term_response, sb); return search_term_response; }
static void AddSearchTermInfo(QueryPart part, SearchTermResponse response, StringBuilder sb) { if (part.Logic == QueryPartLogic.Prohibited) { return; } if (part is QueryPart_Or) { ICollection sub_parts; sub_parts = ((QueryPart_Or)part).SubParts; foreach (QueryPart qp in sub_parts) { AddSearchTermInfo(qp, response, sb); } return; } if (!(part is QueryPart_Text)) { return; } QueryPart_Text tp; tp = (QueryPart_Text)part; string [] split; split = tp.Text.Split(' '); // First, remove stop words for (int i = 0; i < split.Length; ++i) { if (LuceneCommon.IsStopWord(split [i])) { split [i] = null; } } // Assemble the phrase minus stop words sb.Length = 0; for (int i = 0; i < split.Length; ++i) { if (split [i] == null) { continue; } if (sb.Length > 0) { sb.Append(' '); } sb.Append(split [i]); } response.ExactText.Add(sb.ToString()); // Now assemble a stemmed version sb.Length = 0; // clear the previous value for (int i = 0; i < split.Length; ++i) { if (split [i] == null) { continue; } if (sb.Length > 0) { sb.Append(' '); } sb.Append(LuceneCommon.Stem(split [i].ToLower())); } response.StemmedText.Add(sb.ToString()); }
static void AddSearchTermInfo (QueryPart part, SearchTermResponse response, StringBuilder sb) { if (part.Logic == QueryPartLogic.Prohibited) return; if (part is QueryPart_Or) { ICollection sub_parts; sub_parts = ((QueryPart_Or) part).SubParts; foreach (QueryPart qp in sub_parts) AddSearchTermInfo (qp, response, sb); return; } if (! (part is QueryPart_Text)) return; QueryPart_Text tp; tp = (QueryPart_Text) part; string [] split; split = tp.Text.Split (' '); // First, remove stop words for (int i = 0; i < split.Length; ++i) if (LuceneCommon.IsStopWord (split [i])) split [i] = null; // Assemble the phrase minus stop words sb.Length = 0; for (int i = 0; i < split.Length; ++i) { if (split [i] == null) continue; if (sb.Length > 0) sb.Append (' '); sb.Append (split [i]); } response.ExactText.Add (sb.ToString ()); // Now assemble a stemmed version sb.Length = 0; // clear the previous value for (int i = 0; i < split.Length; ++i) { if (split [i] == null) continue; if (sb.Length > 0) sb.Append (' '); sb.Append (LuceneCommon.Stem (split [i].ToLower ())); } response.StemmedText.Add (sb.ToString ()); }