예제 #1
0
        private void DoSearch(Wnlib.Opt opt)
        {
            if (opt.sch.ptp.mnemonic == "OVERVIEW")
            {
                Overview();
                return;
            }

            txtOutput.Text = "";
            Refresh();

            list = new ArrayList();
            se   = new Wnlib.Search(txtSearchWord.Text, true, opt.pos, opt.sch, Int16.Parse(txtSenses.Text));
            int a = se.buf.IndexOf("\\n");

            if ((a >= 0))
            {
                if ((a == 0))
                {
                    se.buf = se.buf.Substring(a + 1);
                    a      = se.buf.IndexOf("\\n");
                }
                StatusBar1.Text = se.buf.Substring(0, a);
                se.buf          = se.buf.Substring(a + 1);
            }
            list.Add(se);
            if ((Wnlib.WNOpt.opt("-h").flag))
            {
                help = new Wnlib.WNHelp(opt.sch, opt.pos).help;
            }
            FixDisplay(opt);
        }
예제 #2
0
        /// <summary>
        /// Fill the top level of the tree.
        /// </summary>
        /// <param name="sch"></param>
        /// <param name="opt">Currently a redundant parameter, but since it holds the search type, it can remain in case search type needs to be known.</param>
        /// <param name="tmppos"></param>
        private void fillTreeRoot(Wnlib.Search sch, ref TreeNode posnode)
        {
            // do the treeview
            //Wnlib.SynSet ss = default(Wnlib.SynSet);
            TreeNode parentnode = null;

            // iterate the returned senses
            foreach (Wnlib.SynSet ss in sch.senses)
            {
                parentnode = newTreeNode(ss);

                // if a part of speech node has been created
                // then it becomes the top level
                if ((posnode != null))
                {
                    posnode.Nodes.Add(parentnode);
                }
                else
                {
                    TreeView1.Nodes.Add(parentnode);
                }

                // do child senses
                if ((ss.senses != null))
                {
                    fillTreeChild(ss.senses, parentnode);
                }

                // fill in sense frames
                //Wnlib.SynSetFrame fr = default(Wnlib.SynSetFrame);
                TreeNode frnode = null;
                if (ss.frames.Count > 0)
                {
                    foreach (Wnlib.SynSetFrame fr in ss.frames)
                    {
                        frnode            = new TreeNode(fr.fr.str);
                        frnode.ImageIndex = 38;
                        parentnode.Nodes.Add(frnode);
                    }
                }
            }
        }
예제 #3
0
        private void DoSearch(Wnlib.Opt opt)
        {
            if (opt.sch.ptp.mnemonic == "OVERVIEW")
            {
                Overview();
                return;
            }

            //TextBox3.Text = ""
            //HtmlViewer1.Document.Window.Close();
            //HtmlViewer1.Navigate("about:blank");
            HtmlViewer1.Document.OpenNew(false);
            HtmlViewer1.Visible = false;
            //TextBox1.Enabled = False
            //lblWait.Visible = True
            //Timer1.Enabled = True
            Refresh();

            list = new ArrayList();
            Wnlib.Search se = new Wnlib.Search(TextBox1.Text, true, opt.pos, opt.sch, int.Parse(TextBox2.Text));
            int          a  = se.buf.IndexOf("\n");

            if ((a >= 0))
            {
                if ((a == 0))
                {
                    se.buf = se.buf.Substring(a + 1);
                    a      = se.buf.IndexOf("\n");
                }
                StatusBar1.Text = se.buf.Substring(0, a);
                se.buf          = se.buf.Substring(a + 1);
            }
            AddHistory(new wnHistory(Strings.Replace(TextBox1.Text, " ", "_"), opt, int.Parse(TextBox2.Text)));
            //        history.Add(New wnHistory(TextBox1.Text, opt, Integer.Parse(TextBox2.Text)))
            list.Add(se);
            if ((Wnlib.WNOpt.opt("-h").flag))
            {
                help = new Wnlib.WNHelp(opt.sch, opt.pos).help;
            }
            FixDisplay();
        }
예제 #4
0
        public void useList(ArrayList w, string help, ref string tmpstr)
        {
            cont     = new ArrayList();
            totLines = 0;
            sw       = null;

            if ((help != null) && !(string.IsNullOrEmpty(help)))
            {
                usePassage(help, ref tmpstr);
            }
            helpLines = totLines;
            int j = 0;

            while (j < w.Count)
            {
                Wnlib.Search se = (Wnlib.Search)w[j];
                sw = se.word;
                usePassage(se.buf, ref tmpstr);
                System.Math.Min(System.Threading.Interlocked.Increment(ref j), j - 1);
            }
        }
예제 #5
0
        /// <summary>
        /// Takes a given Part Of Speech and iterates the Search object to build the
        /// hierarchical output.
        /// </summary>
        /// <param name="sch"></param>
        /// <param name="tmppos"></param>
        /// <returns></returns>
        public string contentIteration(Wnlib.Search sch)
        {
            //Wnlib.SynSet ss = default(Wnlib.SynSet);
            //Wnlib.Lexeme lx = default(Wnlib.Lexeme);
            string outstr = "";

            outstr += "<ul>";

            // iterate the returned senses
            foreach (Wnlib.SynSet ss in sch.senses)
            {
                outstr += "<li>";

                // format the WORDs
                foreach (Wnlib.Lexeme lx in ss.words)
                {
                    outstr += FormatLexeme(lx.word) + ", ";
                }

                // remove last comma
                outstr = Strings.Mid(outstr, 1, outstr.Length - 2);

                outstr += ": ";

                // show the definition
                outstr += FormatDefn(ss.defn);

                // children
                if ((ss.senses != null))
                {
                    outstr += FormatWN(ss.senses);
                }

                outstr += "</li>";
            }

            outstr += "</ul>";

            return(outstr);
        }
예제 #6
0
		private void DoSearch(Wnlib.Opt opt)
		{
			if (opt.sch.ptp.mnemonic == "OVERVIEW") {
				Overview();
				return;
			}

			txtOutput.Text = "";
			Refresh();

			list = new ArrayList();
			se = new Wnlib.Search(txtSearchWord.Text, true, opt.pos, opt.sch, Int16.Parse(txtSenses.Text));
			int a = se.buf.IndexOf("\\n");
			if ((a >= 0)) {
				if ((a == 0)) {
					se.buf = se.buf.Substring(a + 1);
					a = se.buf.IndexOf("\\n");
				}
				StatusBar1.Text = se.buf.Substring(0, a);
				se.buf = se.buf.Substring(a + 1);
			}
			list.Add(se);
			if ((Wnlib.WNOpt.opt("-h").flag)) {
				help = new Wnlib.WNHelp(opt.sch, opt.pos).help;
			}
			FixDisplay(opt);
		}
예제 #7
0
        private int soundsLike(Wnlib.PartOfSpeech pos)
        {
            int    i        = 0;
            int    j        = 0;
            int    x        = 0;
            int    deccount = 0;
            string tmpstr   = "";

            // asc 201 specifies a soundslike
            // adding the trackbar value produces the strength of "sounds like" match
            // between 1 and 3
            //tmpstr = TextBox1.Text & TrackBar1.Value & Chr(201)
            tmpstr = TextBox1.Text + "3" + Strings.Chr(201);

            deccount += 1;

            Wnlib.Search se   = null;
            ArrayList    list = new ArrayList();

            // if searchscrabble is checked then search the official list
            if (chkSearchScrabble.Checked)
            {
                list = EnableDT_Classes.EnableDT_Search.wngrep(tmpstr, radScrabble.Checked);
            }
            else
            {
                se   = new Wnlib.Search(tmpstr, false, pos, new Wnlib.SearchType(false, "WNGREP"), 0, new wildgrep());
                list = se.strings;
            }

            ArrayList tmplist = new ArrayList();

            // delete duplicates
            // ignore errors here = the list may be empty
            try {
                DataRow dr = default(DataRow);
                for (j = 0; j <= list.Count - 1; j++)
                {
                    if (tmplist.Count >= 1)
                    {
                        if (tmplist.IndexOf(list[j]) == -1)
                        {
                            tmplist.Add(list[j]);
                            // **********
                            //                        ListBox1.Items.Add(list[i])
                            dr = dataSet1.Tables[0].NewRow();

                            dr["Word"] = list[j];
                            if (chkSearchScrabble.Checked)
                            {
                                dr["Score"] = ScrabbleScore(list[j].ToString());
                            }
                            dataSet1.Tables[0].Rows.Add(dr);
                            // **********
                        }
                    }
                    else
                    {
                        tmplist.Add(list[j]);
                        //                    ListBox1.Items.Add(list[i])
                        dr = dataSet1.Tables[0].NewRow();

                        dr["Word"] = list[j];
                        if (chkSearchScrabble.Checked)
                        {
                            dr["Score"] = ScrabbleScore(list[j].ToString());
                        }
                        dataSet1.Tables[0].Rows.Add(dr);
                    }
                }

                list = tmplist;
                dataGrid1.DataSource = dataSet1.Tables[0];
            } catch {
            }

            i = list.Count;

            return(i);
        }
예제 #8
0
        private int AnagramScrabble(Wnlib.PartOfSpeech pos)
        {
            int     i        = 0;
            int     j        = 0;
            int     x        = 0;
            int     deccount = 0;
            string  tmpstr   = "";
            DataRow dr       = default(DataRow);

            // TODO: for both anagram search and scrabble search, remove duplicates from the list
            // before processing a word, otherwise the character test is done twice needlessly

            // not a scrabble search, just find the anagram
            if (!radScrabble.Checked)
            {
                // repeat the string into character match blocks for the length of itself
                // eg. kilmo would be [kilmo][kilmo][kilmo][kilmo][kilmo]
                for (j = 1; j <= TextBox1.Text.Length; j++)
                {
                    tmpstr += "[" + TextBox1.Text + "]";
                }

                //        Dim se As Wnlib.Search = New Wnlib.Search(TextBox1.Text, False, pos, New Wnlib.SearchType(False, "WNGREP"), 0)
                Wnlib.Search se   = null;
                ArrayList    list = new ArrayList();

                // if searchscrabble is checked then search the official list
                if (chkSearchScrabble.Checked)
                {
                    list = EnableDT_Classes.EnableDT_Search.wngrep(tmpstr, radScrabble.Checked);
                }
                else
                {
                    se   = new Wnlib.Search(tmpstr, false, pos, new Wnlib.SearchType(false, "WNGREP"), 0, new wildgrep());
                    list = se.strings;
                }

                ArrayList tmplist = new ArrayList();

                //delete(duplicates)
                // ignore errors here = the list may be empty
                try {
                    for (j = 0; j <= list.Count - 1; j++)
                    {
                        if (tmplist.Count >= 1)
                        {
                            if (tmplist.IndexOf(list[j]) == -1)
                            {
                                tmplist.Add(list[j]);
                                // ******
                                if (CheckAnagram(list[j].ToString().ToString(), TextBox1.Text))
                                {
                                    //                                ListBox1.Items.Add(list[i])
                                    dr = dataSet1.Tables[0].NewRow();

                                    dr["Word"] = list[j];
                                    if (chkSearchScrabble.Checked)
                                    {
                                        dr["Score"] = ScrabbleScore(list[j].ToString());
                                    }
                                    dataSet1.Tables[0].Rows.Add(dr);
                                }
                                // ******
                            }
                        }
                        else
                        {
                            tmplist.Add(list[j]);
                            // ******
                            if (CheckAnagram(list[j].ToString().ToString(), TextBox1.Text))
                            {
                                //                            ListBox1.Items.Add(list[i])
                                dr = dataSet1.Tables[0].NewRow();

                                dr["Word"] = list[j];
                                if (chkSearchScrabble.Checked)
                                {
                                    dr["Score"] = ScrabbleScore(list[j].ToString());
                                }
                                dataSet1.Tables[0].Rows.Add(dr);
                            }
                        }
                    }

                    list = tmplist;
                } catch {
                }

                //For j = 0 To list.Count - 1
                //    If CheckAnagram(list[i].ToString(), TextBox1.Text) Then
                //        ListBox1.Items.Add(list[i])
                //    End If
                //Next j

                i = list.Count;
                // scrabble search
            }
            else
            {
                deccount = 0;
                tmpstr   = "";

                // asc 200 specifies a regex
                tmpstr = "^[" + TextBox1.Text + "]+$" + Strings.Chr(200);

                //For x = 1 To TextBox1.Text.Length
                // repeat the string into character match blocks for the length of itself
                // eg. kilmo would be [kilmo][kilmo][kilmo][kilmo][kilmo]
                //For j = 1 To (TextBox1.Text.Length - deccount)
                //    tmpstr += "[" & TextBox1.Text & "]"
                //Next

                deccount += 1;

                Wnlib.Search se   = null;
                ArrayList    list = new ArrayList();

                // if searchscrabble is checked then search the official list
                if (chkSearchScrabble.Checked)
                {
                    list = EnableDT_Classes.EnableDT_Search.wngrep(tmpstr, radScrabble.Checked);
                }
                else
                {
                    se   = new Wnlib.Search(tmpstr, false, pos, new Wnlib.SearchType(false, "WNGREP"), 0, new wildgrep());
                    list = se.strings;
                }

                ArrayList tmplist = new ArrayList();

                // delete duplicates
                // ignore errors here = the list may be empty
                try {
                    for (j = 0; j <= list.Count - 1; j++)
                    {
                        if (tmplist.Count >= 1)
                        {
                            if (tmplist.IndexOf(list[j]) == -1)
                            {
                                tmplist.Add(list[j]);
                                // **********
                                if (CheckAnagram(list[j].ToString().ToString(), TextBox1.Text))
                                {
                                    //ListBox1.Items.Add(list[i])
                                    dr = dataSet1.Tables[0].NewRow();

                                    dr["Word"] = list[j];
                                    if (chkSearchScrabble.Checked)
                                    {
                                        dr["Score"] = ScrabbleScore(list[j].ToString());
                                    }
                                    dataSet1.Tables[0].Rows.Add(dr);
                                }
                                // **********
                            }
                        }
                        else
                        {
                            tmplist.Add(list[j]);
                            // **********
                            if (CheckAnagram(list[j].ToString(), TextBox1.Text))
                            {
                                //                            ListBox1.Items.Add(list[i])
                                dr = dataSet1.Tables[0].NewRow();

                                dr["Word"] = list[j];
                                if (chkSearchScrabble.Checked)
                                {
                                    dr["Score"] = ScrabbleScore(list[j].ToString());
                                }
                                dataSet1.Tables[0].Rows.Add(dr);
                            }
                        }
                    }

                    list = tmplist;
                } catch {
                }

                i      = list.Count;
                tmpstr = "";
                //Next
                //DataGrid1.TableStyles(0).GridColumnStyles(0).Width = 200
                //DataGrid1.TableStyles(0).GridColumnStyles(1).Width = 100
            }

            dataGrid1.DataSource = dataSet1.Tables[0];

            return(i);
        }
예제 #9
0
        private int WildCardRegex(Wnlib.PartOfSpeech pos)
        {
            int    i        = 0;
            int    j        = 0;
            int    x        = 0;
            int    deccount = 0;
            string tmpstr   = "";

            // TODO: for both anagram search and scrabble search, remove duplicates from the list
            // before processing a word, otherwise the character test is done twice needlessly

            // not a scrabble search, just find the anagram
            if (!radRegularExpression.Checked)
            {
                tmpstr = TextBox1.Text;
            }
            else
            {
                tmpstr = TextBox1.Text + Strings.Chr(200);
            }

            Wnlib.Search se   = null;
            ArrayList    list = new ArrayList();

            // if searchscrabble is checked then search the official list
            if (chkSearchScrabble.Checked)
            {
                list = EnableDT_Classes.EnableDT_Search.wngrep(tmpstr, radScrabble.Checked);
            }
            else
            {
                se   = new Wnlib.Search(tmpstr, false, pos, new Wnlib.SearchType(false, "WNGREP"), 0, new wildgrep());
                list = se.strings;
            }

            ArrayList tmplist = new ArrayList();

            if (list.IndexOf("error") != -1)
            {
                return(-1);
            }

            //delete(duplicates)
            // ignore errors here = the list may be empty
            try {
                DataRow dr = default(DataRow);
                for (j = 0; j <= list.Count - 1; j++)
                {
                    if (tmplist.Count >= 1)
                    {
                        if (tmplist.IndexOf(list[j]) == -1)
                        {
                            tmplist.Add(list[j]);
                            // ******
                            //ListBox1.Items.Add(list[i])
                            dr = dataSet1.Tables[0].NewRow();

                            dr["Word"] = list[j];
                            if (chkSearchScrabble.Checked)
                            {
                                dr["Score"] = ScrabbleScore(list[j].ToString());
                            }
                            dataSet1.Tables[0].Rows.Add(dr);
                            // ******
                        }
                    }
                    else
                    {
                        tmplist.Add(list[j]);
                        // ******
                        //                    ListBox1.Items.Add(list[i])
                        dr = dataSet1.Tables[0].NewRow();

                        dr["Word"] = list[i];
                        if (chkSearchScrabble.Checked)
                        {
                            dr["Score"] = ScrabbleScore(list[i].ToString());
                        }
                        dataSet1.Tables[0].Rows.Add(dr);
                        // ******
                    }
                }

                list = tmplist;

                dataGrid1.DataSource = dataSet1.Tables[0];
            } catch {
            }

            //For j = 0 To list.Count - 1
            //    If CheckAnagram(list[i].ToString(), TextBox1.Text) Then
            //        ListBox1.Items.Add(list[i])
            //    End If
            //Next j

            i = list.Count;

            return(i);
        }