Exemplo n.º 1
0
        private void btnRetreiveFromIndex_Click(object sender, EventArgs e)
        {
            // QUERY TEST
            Stopwatch sw = Stopwatch.StartNew();

            //var freeTextQuery = new FreeTextQuery("Bible", path, new CultureInfo("en-US"));
            //var freeTextQuery = new FreeTextQuery(new TextFileAccessContext("Bible", path, new CultureInfo("en-US")));
            if (Query == null)
            {
                Query = LoadIndex();
            }

            List <QueryResult <int> > result = Query.SearchFreeTextQuery(IndexReader.GetTextIndex(), txtCriteria.Text);

            sw.Stop();

            previousQuery     = result;
            lblStopwatch.Text = string.Format("Query took: {0} MS / # Of Rows: {1}", sw.Elapsed.TotalMilliseconds, result.Count);

            lbResults.Items.Clear();
            foreach (QueryResult <int> r in result)
            {
                lbResults.Items.Add(string.Format("{0};\t Key: {1};\t Rank: {2};\t MO: {3};\t LPI: {4};\t STP: {5};\t WM: {6}",
                                                  string.Join(", ", r.WordIndexes.Select(v => v.Word).ToArray()), r.Key, r.Rank, r.multipleOccurance, r.lowPhraseIndex, r.searchTermsProximity, r.wordMatching));
            }
        }
Exemplo n.º 2
0
        public void x(string searchTerm)
        {
            var index = ScenarioContext.Current.Get <TextIndex <int> >();

            var mock = new Mock <IThesaurusDictionaryRetriever>();

            mock.Setup(x => x.GetThesaurus())
            .Returns(new SortedList <string, SortedList <string, int> >());
            var thesaurus = new DefaultThesaurus(mock.Object);

            var wordBreakingInformationRetriever = new Mock <IWordBreakingInformationRetriever>();

            wordBreakingInformationRetriever.Setup(x => x.GetWordBreakingInformation())
            .Returns(new WordBreakingInformation {
                NoiseWords    = new Dictionary <string, string>(),
                Substitutions = new Dictionary <string, string>(),
                Whitespace    = new List <char>()
            });

            var query   = new FreeTextQuery <int>(new DefaultWordBreaker(wordBreakingInformationRetriever.Object), thesaurus, new WordRefEqualityComparer <int>(), new TextIndexSearcher <int>());
            var results = query.SearchFreeTextQuery(index, searchTerm);

            ScenarioContext.Current.Set(results.Select(x => x));
        }