// Method to take users query text as input // and does various things to it to produce // the a query that is input to the searcher private Query PreprocessQuery(string origText, QueryParser parser) { // builds a boolean query // partA is just the original query text string partA = origText; // partB is bi- and tri-grams built from the original text // build ngrams int ngram_num = 3; List <string> tokens = TextProcessing.TokeniseString(origText); List <string> ngrams = TextProcessing.getNGrams(tokens, ngram_num); string partB = string.Join(" ", ngrams); // Build BooleanQuery BooleanQuery bQuery = new BooleanQuery(); Query queryA = parser.Parse(partA); Query queryB = parser.Parse(partB); bQuery.Add(queryA, Occur.MUST); bQuery.Add(queryB, Occur.MUST); return(bQuery); }
// provide the results summary info for results view public override string[] GetResultSummary() { return(new string[] { title, author, biblioInfo, TextProcessing.GetFirstSentence(words) }); }