//Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged // Dim t As String // If TextBox1.Lines.Length > 1 Then // t = TextBox1.Lines(0) // Label2.Text = "Searches for " + t + ":" // Label2.Visible = True // Overview() // End If //End Sub private void Overview() { //overview for 'search' string t = null; t = TextBox1.Text; Label2.Text = "Searches for " + t + ":"; Label2.Visible = true; Button1.Visible = false; // TextBox3.Text = "" //HtmlViewer1.Document.close() //TextBox3.Visible = False //TextBox1.Enabled = False //lblWait.Visible = True // Timer1.Enabled = True StatusBar1.Text = "Overview of " + t; Refresh(); try { // sets the visibility of noun, verb, adj, adv when showing buttons for a word //Stop list = new ArrayList(); bool b = true; wnc.OverviewFor(t, "noun", ref b, ref bobj2, list); Button2.Visible = b; b = true; wnc.OverviewFor(t, "verb", ref b, ref bobj3, list); Button3.Visible = b; b = true; wnc.OverviewFor(t, "adj", ref b, ref bobj4, list); Button4.Visible = b; b = true; wnc.OverviewFor(t, "adv", ref b, ref bobj5, list); Button5.Visible = b; TextBox1.Text = t; //btnSearch.Visible = False TextBox2.Text = "0"; AddHistory(new wnHistory(Strings.Replace(t, " ", "_"), Wnlib.Opt.at(Wnlib.Opt.Count - 1), 0)); // history.Add(New wnHistory(t, Wnlib.Opt.at(Wnlib.Opt.Count - 1), 0)) } catch (System.Exception ex) { MessageBox.Show(ex.Message); } FixDisplay(); }
private void testoverview(string pos) { SearchSet bobj = null; // = new SearchSet(); WordNetClasses.WN wnc = new WordNetClasses.WN(@"C:\Program Files\WordNet\3.0\dict\"); bool b = false;// sets word found - true/false ArrayList list; System.IO.StreamReader indexFile = new System.IO.StreamReader(@"C:\Program Files\WordNet\3.0\dict\index." + pos); //StreamWriter foundNouns = new StreamWriter(@"C:\found " + pos + ".txt"); StreamWriter lostNouns = new StreamWriter(@"C:\lost " + pos + ".txt"); string currentLine = indexFile.ReadLine(); string indexLine = string.Empty; while (currentLine != null) { string currentWord = currentLine.Substring(0, currentLine.IndexOf(' ')); // this transformation doesn't reflect the library's // true transformations - it transforms internally // in index lookup //currentWord = currentWord.Replace("-"," ").Replace("_"," "); //currentWord = currentWord.Replace("_"," "); if (currentWord.Length > 0) { list = new ArrayList(); wnc.OverviewFor(currentWord, pos, ref b, ref bobj, list); if (!b) { // set a breakpoint here to single-step and find // out why a word isn't picked up from the index wnc.OverviewFor(currentWord, pos, ref b, ref bobj, list); lostNouns.WriteLine(currentWord); } else { //foundNouns.WriteLine(currentWord); } } currentLine = indexFile.ReadLine(); } //foundNouns.Close(); lostNouns.Close(); MessageBox.Show("done"); }
/// <summary> /// This is an overview search - the basis for any advanced search. /// </summary> private void Overview() { //overview for 'search' string t = null; WordNetClasses.WN wnc = new WordNetClasses.WN(dictpath); se = null; // prevent the output from being overwritten by old results in showresults t = txtSearchWord.Text; lblSearchInfo.Text = "Searches for " + t + ":"; lblSearchInfo.Visible = true; btnOverview.Visible = false; // txtOutput.Text = "" // txtOutput.Visible = False StatusBar1.Text = "Overview of " + t; Refresh(); try { bool b = false; // sets the visibility of noun, verb, adj, adv when showing buttons for a word list = new ArrayList(); wnc.OverviewFor(t, "noun", ref b, ref bobj2, list); btnNoun.Visible = b; wnc.OverviewFor(t, "verb", ref b, ref bobj3, list); btnVerb.Visible = b; wnc.OverviewFor(t, "adj", ref b, ref bobj4, list); btnAdj.Visible = b; wnc.OverviewFor(t, "adv", ref b, ref bobj5, list); btnAdv.Visible = b; txtSearchWord.Text = t; txtSenses.Text = "0"; string outstr = ""; outstr = wnColour.buildContents(list); wnColour.Canvas.DocumentText = outstr; } catch (Exception ex) { MessageBox.Show(ex.Message + Constants.vbCrLf + Constants.vbCrLf + "Princeton's WordNet not pre-installed to default location?"); } FixDisplay(null); }
public static ArrayList GetSenses(string pos, string noun) { string pos2 = null; switch (pos) { case "N": pos2 = "noun"; break; case "V": pos2 = "verb"; break; case "A": pos2 = "adj"; break; case "R": pos2 = "adv"; break; } bool b = false; SearchSet boj = null; ArrayList list = new ArrayList(); wnc.OverviewFor(noun, pos2, ref b, ref boj, list); ArrayList senses = new ArrayList(); for (int i = 0; i < list.Count; i++) { Search vs = (Search)list[i]; int cut = (int)Math.Ceiling(vs.senses.Count * percent / 100.0); if (cut < threshold) { cut = threshold; } if (vs.taggedSenses > 0 && tagged_only) { cut = vs.taggedSenses; } foreach (SynSet ss in vs.senses) { if (--cut < 0) { break; } senses.Add((vs.word + '#' + pos + '#' + (ss.sense + 1).ToString()).ToLower()); } } return(senses); }
/// <summary> /// This is an overview search - the basis for any advanced search. /// </summary> private void Overview() { //overview for 'search' string t = null; WordNetClasses.WN wnc = new WordNetClasses.WN(dictpath); se = null; // prevent the output from being overwritten by old results in showresults t = txtSearchWord.Text; lblSearchInfo.Text = "Searches for " + t + ":"; lblSearchInfo.Visible = true; btnOverview.Visible = false; // txtOutput.Text = "" // txtOutput.Visible = False StatusBar1.Text = "Overview of " + t; Refresh(); try { bool b = false; // sets the visibility of noun, verb, adj, adv when showing buttons for a word list = new ArrayList(); wnc.OverviewFor(t, "noun", ref b, ref bobj2, list); btnNoun.Visible = b; wnc.OverviewFor(t, "verb", ref b, ref bobj3, list); btnVerb.Visible = b; wnc.OverviewFor(t, "adj", ref b, ref bobj4, list); btnAdj.Visible = b; wnc.OverviewFor(t, "adv", ref b, ref bobj5, list); btnAdv.Visible = b; txtSearchWord.Text = t; txtSenses.Text = "0"; string outstr = ""; outstr = wnColour.buildContents(list); wnColour.Canvas.DocumentText = outstr; } catch (Exception ex) { MessageBox.Show(ex.Message + Constants.vbCrLf + Constants.vbCrLf + "Princeton's WordNet not pre-installed to default location?"); } FixDisplay(null); }
private void testoverview(string pos) { SearchSet bobj = null; // = new SearchSet(); WordNetClasses.WN wnc = new WordNetClasses.WN(@"C:\Program Files\WordNet\3.0\dict\"); bool b = false; // sets word found - true/false ArrayList list; System.IO.StreamReader indexFile = new System.IO.StreamReader(@"C:\Program Files\WordNet\3.0\dict\index." + pos); //StreamWriter foundNouns = new StreamWriter(@"C:\found " + pos + ".txt"); StreamWriter lostNouns = new StreamWriter(@"C:\lost " + pos + ".txt"); string currentLine = indexFile.ReadLine(); string indexLine = string.Empty; while (currentLine != null) { string currentWord = currentLine.Substring(0, currentLine.IndexOf(' ')); // this transformation doesn't reflect the library's // true transformations - it transforms internally // in index lookup //currentWord = currentWord.Replace("-"," ").Replace("_"," "); //currentWord = currentWord.Replace("_"," "); if (currentWord.Length > 0) { list = new ArrayList(); wnc.OverviewFor(currentWord, pos, ref b, ref bobj, list); if (!b) { // set a breakpoint here to single-step and find // out why a word isn't picked up from the index wnc.OverviewFor(currentWord, pos, ref b, ref bobj, list); lostNouns.WriteLine(currentWord); } else { //foundNouns.WriteLine(currentWord); } } currentLine = indexFile.ReadLine(); } //foundNouns.Close(); lostNouns.Close(); MessageBox.Show("done"); }