コード例 #1
0
        /// <summary>
        /// Handles all word relationship menu selections.  Performs a relationship search.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void searchMenu_Click(object sender, System.EventArgs e)
        {
            // one of the options for button2_click was selected
            MenuItem mi = (MenuItem)sender;

            Wnlib.Opt opt    = null;
            int       i      = 0;
            string    tmpstr = null;

            txtOutput.Text  = "";
            tmpstr          = mi.Text;
            tmpstr          = Strings.Replace(tmpstr, "Syns", "Synonyms");
            tmpstr          = Strings.Replace(tmpstr, " x ", " by ");
            tmpstr          = Strings.Replace(tmpstr, "Freq:", "Frequency:");
            StatusBar1.Text = tmpstr;
            Refresh();

            for (i = 0; i <= mi.Parent.MenuItems.Count - 1; i++)
            {
                if (mi.Text == mi.Parent.MenuItems[i].Text)
                {
                    opt = (Wnlib.Opt)opts[i];
                }
            }
            DoSearch(opt);
            btnOverview.Visible = true;

            Refresh();
        }
コード例 #2
0
        /// <summary>
        /// Helper for displaying output and associated housekeeping.
        /// </summary>
        /// <param name="opt"></param>
        public void FixDisplay(Wnlib.Opt opt)
        {
            pbobject = "";
            ShowResults(opt);

            txtSearchWord.Focus();
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: StartForm.cs プロジェクト: xinxu1018/wordnetdotnet
        private void LoadHistory()
        {
            System.IO.StreamReader f = null;

            try {
                f = new System.IO.StreamReader(MyPath() + "\\history.txt");
            } catch (System.Exception ex) {
                return;
                // no history file to load
            }

            try {
                string s = null;

                while (1 == 1)
                {
                    s = f.ReadLine();
                    if (s == null)
                    {
                        break;                         // TODO: might not be correct. Was : Exit While
                    }

                    Wnlib.StrTok st = new Wnlib.StrTok(s);
                    string       w  = st.next();
                    int          i  = int.Parse(st.next());
                    int          sn = int.Parse(st.next());

                    Wnlib.Opt opt = Wnlib.Opt.at(i);
                    AddHistory(new wnHistory(Strings.Replace(w, " ", "_"), opt, sn));
                    //                history.Add(New wnHistory(w, opt, sn))
                }
                f.Close();
            } catch (System.Exception ex) {
                Interaction.MsgBox(ex.Message);
            }

            if ((history.Count == 0))
            {
                MenuItem mi    = mnuHistory;
                MenuItem mitem = new MenuItem();
                // (opt.label, AddressOf searchMenu_Click)
                mitem.Text = "<empty>";
                mi.MenuItems.Add(mitem);
                return;
            }
        }
コード例 #5
0
ファイル: StartForm.cs プロジェクト: xinxu1018/wordnetdotnet
        private void searchMenu_Click(object sender, System.EventArgs e)
        {
            // one of the options for button2_click was selected
            MenuItem mi = (MenuItem)sender;

            Wnlib.Opt opt = null;
            //= opts(mi.MenuItems.IndexOf(mi))
            int    i      = 0;
            string tmpstr = null;

            //System.Windows.Forms.Application.DoEvents()
            //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
            tmpstr          = mi.Text;
            tmpstr          = Strings.Replace(tmpstr, "Syns", "Synonyms");
            tmpstr          = Strings.Replace(tmpstr, " x ", " by ");
            tmpstr          = Strings.Replace(tmpstr, "Freq:", "Frequency:");
            StatusBar1.Text = tmpstr;
            Refresh();

            for (i = 0; i <= mi.Parent.MenuItems.Count - 1; i++)
            {
                if (mi.Text == mi.Parent.MenuItems[i].Text)
                {
                    opt = (Wnlib.Opt)opts[i];
                }
            }
            DoSearch(opt);
            Button1.Visible = true;

            //System.Windows.Forms.Application.DoEvents()
            HtmlViewer1.Visible = true;
            //TextBox1.Enabled = True
            //Timer1.Enabled = False
            Refresh();
        }
コード例 #6
0
ファイル: StartForm.cs プロジェクト: xinxu1018/wordnetdotnet
        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();
        }
コード例 #7
0
ファイル: StartForm.cs プロジェクト: xinxu1018/wordnetdotnet
        private void Button2Click(System.Object sender, System.EventArgs e)
        {
            // handles noun, verb, adj, adverb click for context menu
            Button b = (Button)sender;

            Wnlib.SearchSet ss = null;
            //= bobj2
            string btext = b.Text;

            if (btext == "Adjective")
            {
                btext = "Adj";
            }

            switch (btext)
            {
            case "Noun":
                ss = (Wnlib.SearchSet)bobj2;

                break;

            case "Verb":
                ss = (Wnlib.SearchSet)bobj3;

                break;

            case "Adj":
                ss = (Wnlib.SearchSet)bobj4;

                break;

            case "Adverb":
                ss = (Wnlib.SearchSet)bobj5;
                break;
            }
            Wnlib.PartOfSpeech pos = Wnlib.PartOfSpeech.of(btext.ToLower());
            int i = 0;

            opts = new ArrayList();
            ContextMenu cm     = new ContextMenu();
            ArrayList   tmplst = new ArrayList();

            for (i = 0; i <= Wnlib.Opt.Count - 1; i++)
            {
                Wnlib.Opt opt = Wnlib.Opt.at(i);

                //Try ' TODO: fix problem with adjective menu
                if (ss[opt.sch.ptp.ident] & object.ReferenceEquals(opt.pos, pos))
                {
                    if (tmplst.IndexOf(opt.label) == -1 & opt.label != "Grep")
                    {
                        MenuItem mi = new MenuItem();
                        // (opt.label, AddressOf searchMenu_Click)
                        mi.Text   = opt.label;
                        mi.Click += searchMenu_Click;
                        opts.Add(opt);
                        cm.MenuItems.Add(mi);

                        tmplst.Add(opt.label);
                    }
                }
                //Catch
                //End Try
            }

            cm.Show(b.Parent, new System.Drawing.Point(b.Left, b.Bottom));
            //Point(b.Left, b.Bottom))
        }
コード例 #8
0
ファイル: StartForm.cs プロジェクト: xinxu1018/wordnetdotnet
 public wnHistory(string w, Wnlib.Opt o, int s)
 {
     word = w;
     opt  = o;
     sn   = s;
 }
コード例 #9
0
        /// <summary>
        /// Handles the sense buttons to build and display the appropriate dropdown menu for
        /// searches on word relationships.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnWordType_Click(System.Object sender, System.EventArgs e)
        {
            Button b = (Button)sender;

            Wnlib.SearchSet ss    = null;
            string          btext = b.Text;

            if (btext == "Adjective")
            {
                btext = "Adj";
            }

            switch (btext)
            {
            case "Noun":
                ss = (Wnlib.SearchSet)bobj2;

                break;

            case "Verb":
                ss = (Wnlib.SearchSet)bobj3;

                break;

            case "Adj":
                ss = (Wnlib.SearchSet)bobj4;

                break;

            case "Adverb":
                ss = (Wnlib.SearchSet)bobj5;
                break;
            }

            Wnlib.PartOfSpeech pos = Wnlib.PartOfSpeech.of(btext.ToLower());
            int i = 0;

            opts = new ArrayList();
            ContextMenu cm     = new ContextMenu();
            ArrayList   tmplst = new ArrayList();

            for (i = 0; i <= Wnlib.Opt.Count - 1; i++)
            {
                Wnlib.Opt opt = Wnlib.Opt.at(i);                 //opt.at(i);

                if (ss[opt.sch.ptp.ident] & object.ReferenceEquals(opt.pos, pos))
                {
                    if (tmplst.IndexOf(opt.label) == -1 & opt.label != "Grep")
                    {
                        MenuItem mi = new MenuItem();
                        mi.Text   = opt.label;
                        mi.Click += searchMenu_Click;
                        opts.Add(opt);
                        cm.MenuItems.Add(mi);

                        tmplst.Add(opt.label);
                    }
                }
            }
            cm.Show(b.Parent, new Point(b.Left, b.Bottom));
        }
コード例 #10
0
        /// <summary>
        /// Displays the results of the search.
        /// </summary>
        /// <param name="opt">The opt object holds the user-defined search options</param>
        private void ShowResults(Wnlib.Opt opt)
        {
            string tmpstr = "";

            if (list.Count == 0)
            {
                showFeedback("Search for " + txtSearchWord.Text + " returned 0 results.");
                return;
            }

            Overview tmptbox = new Overview();

            if ((!object.ReferenceEquals(pbobject.GetType(), tmptbox.GetType())))
            {
                Overview tb = new Overview();
                txtOutput.Text = "";
                tb.useList(list, help, ref tmpstr);
                if ((help != null) & !string.IsNullOrEmpty(help))
                {
                    tmpstr = help + Constants.vbCrLf + Constants.vbCrLf + tmpstr;
                }
                tmpstr = Strings.Replace(tmpstr, Constants.vbLf, Constants.vbCrLf);
                tmpstr = Strings.Replace(tmpstr, Constants.vbCrLf, "", 1, 1);
                tmpstr = Strings.Replace(tmpstr, "_", " ");
                showFeedback(tmpstr);

                if (string.IsNullOrEmpty(tmpstr) | tmpstr == "<font color='green'><br />" + Constants.vbCr + " " + txtSearchWord.Text + " has no senses </font>")
                {
                    showFeedback("Search for " + txtSearchWord.Text + " returned 0 results.");
                }
                txtOutput.Visible = true;
                pbobject          = tb;
            }

            txtSearchWord.Focus();

            if ((se != null))
            {
                if (se.morphs.Count > 0)
                {
                    // use morphs instead of se
                    string wrd = null;

                    list = new ArrayList();

                    foreach (string wrd_loopVariable in se.morphs.Keys)
                    {
                        wrd = wrd_loopVariable;
                        // Build the treecontrol with the search results.
                        // Node hierarchy is automatically constructed in the TreeControl.
                        list.Add(se.morphs[wrd]);
                        treeControl1.fillTree(list, false);
                    }
                }
                else
                {
                    // there are no morphs - all senses exist in se
                    // Build the treecontrol with the search results.
                    // Node hierarchy is automatically constructed in the TreeControl.
                    list = new ArrayList();
                    list.Add(se);
                    treeControl1.fillTree(list, false);
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Displays the results of the search.
        /// </summary>
        /// <param name="opt">The opt object holds the user-defined search options</param>
        private void ShowResults(Wnlib.Opt opt)
        {
            string tmpstr = "";

            if (list.Count == 0)
            {
                showFeedback("Search for " + txtSearchWord.Text + " returned 0 results.");
                return;
            }

            Overview tmptbox = new Overview();

            if ((!object.ReferenceEquals(pbobject.GetType(), tmptbox.GetType())))
            {
                Overview tb = new Overview();
                tb.useList(list, help, ref tmpstr);
                if ((help != null) & !string.IsNullOrEmpty(help))
                {
                    tmpstr = help + Constants.vbCrLf + Constants.vbCrLf + tmpstr;
                }
                tmpstr = Strings.Replace(tmpstr, Constants.vbLf, Constants.vbCrLf);
                tmpstr = Strings.Replace(tmpstr, Constants.vbCrLf, "", 1, 1);
                tmpstr = Strings.Replace(tmpstr, "_", " ");
                showFeedback(tmpstr);

                if (string.IsNullOrEmpty(tmpstr) | tmpstr == "<font color='green'><br />" + Constants.vbCr + " " + txtSearchWord.Text + " has no senses </font>")
                {
                    showFeedback("Search for " + txtSearchWord.Text + " returned 0 results.");
                }
                pbobject = tb;
            }

            txtSearchWord.Focus();

            if ((se != null))
            {
                string outstr = "";

                if (se.morphs.Count > 0)
                {
                    // use morphs instead of se
                    string wrd = null;

                    foreach (string wrd_loopVariable in se.morphs.Keys)
                    {
                        wrd = wrd_loopVariable;
                        // Build the output with the search results.
                        // Node hierarchy is automatically constructed
                        list    = null;
                        list[0] = se.morphs[wrd];
                        outstr  = wnColour.buildContents(list);
                    }
                }
                else
                {
                    // there are no morphs - all senses exist in se
                    // Build the output with the search results.
                    // Node hierarchy is automatically constructed
                    list[0] = se;
                    outstr  = wnColour.buildContents(list);
                }

                wnColour.Canvas.DocumentText = outstr;
            }
        }