protected void Button1_Click(object sender, EventArgs e)
        {
            DropDownList1.Items.Clear();

            //Spell Checking
            if (RadioButton1.Checked)
            {
                searching se = new searching();
                correct_words = se.Spell_Checking(TextBox1.Text);

                //Add the correct words into dropdownlist
                for (int i = 0; i < correct_words.Count; i++)
                {
                    DropDownList1.Items.Add(correct_words[i]);
                }
            }
            List <string> retDocs = new List <string>();
            searching     s       = new searching();

            retDocs = s.search(TextBox1.Text);
            List <string> uniDocs = new List <string>();

            for (int i = 0; i < retDocs.Count; i++)
            {
                if (!uniDocs.Contains(retDocs[i]))
                {
                    uniDocs.Add(retDocs[i]);
                }
            }

            //add the returned urls into the listbox
            for (int i = 0; i < uniDocs.Count; i++)
            {
                ListBox1.Items.Add(uniDocs[i]);
            }
        }
Beispiel #2
0
    private static void Main()
    {
        searching obj = new searching();

        string[] words = new string[20];
        char[]   c     = new char[50];
        Console.WriteLine("\nEnter the search_engine_input: ");
        obj.search_engine_input = Console.ReadLine();
        obj.m = obj.search_engine_input.Length;
        Console.WriteLine("m= " + obj.m);
        int p = 0, wi = 0, num_of_words = 0;

        while (p < obj.search_engine_input.Length)
        {
            if (obj.search_engine_input[p] != ' ')
            {
                c[wi] = obj.search_engine_input[p];
                wi++;
            }
            else
            {
                //c[wi] = '\0';
                int    k  = 0;
                char[] ch = new char[wi];
                while (k < wi)
                {
                    ch[k] = c[k];
                    k++;
                }

                words[num_of_words] = new string(ch);
                num_of_words++;
                wi = 0;
            }
            p++;
        }
        //c[wi] = '\0';
        int k2 = 0;

        char[] ch2 = new char[wi];
        while (k2 < wi)
        {
            ch2[k2] = c[k2];
            k2++;
        }
        words[num_of_words] = new string(ch2);
        num_of_words++;
        p = 0;
        Console.WriteLine("num of words=" + (num_of_words));
        obj.m = obj.search_engine_input.Length;
        while (p < num_of_words)
        {
            Console.WriteLine("word number = " + (p + 1) + " is " + words[p] + "    lenghth =" + words[p].Length);
            p++;
        }
        p = 0;
        while (p < num_of_words)
        {
            obj.n = words[p].Length;
            i     = 0;
            obj.kmp(words[p]);
            p++;
        }
        Console.ReadLine();
    }