Exemplo n.º 1
0
        private void NextButton_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = " ";
            List <string>         result   = new List <string>();
            List <List <string> > myResult = new List <List <string> >();

            myResult = myLucene.OutPut2(TextEnter.Text, currentPage, Source.Text, Index.Text);
            button   = getButton();
            myLucene = new LuceneAdvancedSearchApplication(button);
            if (currentPage < int.Parse(myResult[2][0]))
            {
                myResult     = myLucene.OutPut2(TextEnter.Text, currentPage + 1, Source.Text, Index.Text);
                currentPage += 1;
                CreateButton(myResult[0], myResult[1]);
            }
            else
            {
                myResult = myLucene.OutPut2(TextEnter.Text, int.Parse(myResult[2][0]), Source.Text, Index.Text);
                CreateButton(myResult[0], myResult[1]);
            }

            for (int i = 0; i < myResult[0].Count; i++)
            {
                richTextBox1.Text += myResult[0][i];
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello Lucene.Net");

            LuceneAdvancedSearchApplication myLuceneApp = new LuceneAdvancedSearchApplication();

            // source collection
            List <string> l = new List <string>();

            l.Add("The magical world of oz");
            l.Add("The mad, mad, mad, mad world");
            l.Add("Possum magic");
            l.Add("Mad isn't bad");
            l.Add("Mad's greatest hits");


            // Index code
            string indexPath = @"C:\Week_6\";

            myLuceneApp.CreateIndex(indexPath);
            System.Console.WriteLine("Adding Documents to Index");
            int docID = 0;

            foreach (string s in l)
            {
                System.Console.WriteLine("Adding doc " + docID + ". " + s + "  to Index");
                myLuceneApp.IndexText(s);
                docID++;
            }
            System.Console.WriteLine("All documents added.");
            Console.WriteLine("------------------------------------------------------");
            Console.WriteLine();
            myLuceneApp.CleanUpIndexer();

            // Searching Code
            myLuceneApp.CreateSearcher();

            string[] queries    = { "mad", "world", "mad^2 world", "\"mad world\"", "\"mad world\" mad world" };
            int      countQuery = 0;

            foreach (string query in queries)
            {
                countQuery++;
                Console.Write($"Query {countQuery} ");
                myLuceneApp.SearchText(query);
                Console.WriteLine();
            }


            myLuceneApp.CleanUpSearcher();


            Console.ReadLine();
        }
Exemplo n.º 3
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            richTextBox1.Text = " ";

            List <List <string> > myResult = new List <List <string> >();

            button = getButton();

            myLucene = new LuceneAdvancedSearchApplication(button);

            myResult = myLucene.OutPut(TextEnter.Text, currentPage, Source.Text, Index.Text);
            //if (buttonPanel.Contains(dynamicButton))
            //{
            //    buttonPanel.Controls.Clear();
            //}
            Console.WriteLine(myResult[0].Count);
            CreateButton(myResult[0], myResult[1]);

            //int j = 0;
            //int k = 0;
            //int length = 0;
            for (int i = 0; i < myResult[0].Count; i++)
            {
                richTextBox1.Text += myResult[0][i];


                //if (i % 2 == 0)
                //{
                //    label1.Text = result[i];
                //    richTextBox1.Select(length, result[i].Length);
                //    //richTextBox1.SelectionFont = new Font("Tahoma", 12, FontStyle.Bold);
                //    richTextBox1.SelectionColor = System.Drawing.Color.Red;
                //    length += result[i].Length;
                //}
                //else
                //{
                //    label2.Text = result[i];
                //    //j += j;
                //    richTextBox1.Select(length, result[i].Length);
                //    //richTextBox1.SelectionFont = new Font("Tahoma", 10, FontStyle.Regular);
                //    richTextBox1.SelectionColor = Color.Black;
                //    length += result[i].Length;
                //}
            }
            NumberOfresults.Text = myResult[3][0];
            querylabel.Text      = myResult[4][0];
            //label1.Text = k.ToString();
            //label2.Text = j.ToString();
            //Console.WriteLine(result);
            //richTextBox1.Text = myLucene.OutPut(TextEnter.Text, 1);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello Lucene.Net");

            LuceneAdvancedSearchApplication myLuceneApp = new LuceneAdvancedSearchApplication();

            // source collection
            List <string> l = new List <string>();

            l.Add("The magical world of oz");
            l.Add("The mad, mad, mad, mad world");
            l.Add("Possum magic");
            l.Add("Mad isn't bad");
            l.Add("Mad's greatest hits");


            // Index code
            string indexPath = @"C:\Users\n10104844\source\repos\IFN647-Practical\Practical 6\Week6_Index";

            myLuceneApp.CreateIndex(indexPath);
            System.Console.WriteLine("Adding Documents to Index");
            int docID = 0;

            foreach (string s in l)
            {
                System.Console.WriteLine("Adding doc " + docID + ". " + s + "  to Index");
                myLuceneApp.IndexText(s);
                docID++;
            }
            System.Console.WriteLine("All documents added.");
            myLuceneApp.CleanUpIndexer();

            // Searching Code
            myLuceneApp.CreateSearcher();
            myLuceneApp.SearchText("mad^2 world^5");           //boost, frequency of the mad is higher so that The mad mad mad world is at rank 1
            //myLuceneApp.SearchText("\"mad world\"");//excape the " for input a phrase
            myLuceneApp.SearchText("\"mad world\" mad world"); //higher score => "Query expansion"
            //Lucene's search strategy first implement boolean and next
            myLuceneApp.CleanUpSearcher();


            Console.ReadLine();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello Lucene.Net");

            LuceneAdvancedSearchApplication myLuceneApp = new LuceneAdvancedSearchApplication();

            // source collection
            List <string> l = new List <string>();

            l.Add("The magical world of oz");
            l.Add("The mad, mad, mad, mad world");
            l.Add("Possum magic");
            l.Add("Mad isn't bad");
            l.Add("Mad's greatest hits");


            // Index code
            string indexPath = @"./index";

            myLuceneApp.CreateIndex(indexPath);
            System.Console.WriteLine("Adding Documents to Index");
            int docID = 0;

            foreach (string s in l)
            {
                System.Console.WriteLine("Adding doc " + docID + ". " + s + "  to Index");
                myLuceneApp.IndexText(s);
                docID++;
            }
            System.Console.WriteLine("All documents added.!!!!");
            myLuceneApp.CleanUpIndexer();

            // Searching Code
            myLuceneApp.CreateSearcher();

            myLuceneApp.SearchText("mad");

            myLuceneApp.CleanUpSearcher();


            Console.ReadLine();
        }