public WSD(bool tagged, int Threshold, int Percent) { threshold = Threshold; percent = Percent; tagged_only = tagged; wnc = new WordNetClasses.WN(Wnlib.WNCommon.path); control = new WSD_ControlClass(); control.Algorithm = "WordNet::SenseRelate::Algorithm::Global"; control.WNpath = "../../../dict"; control.Measure = "WordNet::Similarity::lesk"; control.Config = "../../../config/config-lesk.conf"; }
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); }
/// <summary> /// This method add synonyms word to the term in the query using to kinds of external tool. first is the word net project, second /// is the hunspell thesaures dictionary /// </summary> /// <param name="query"></param> /// <returns></returns> public List <string> AddSemantic(List <string> query) { WordNetClasses.WN wnc = new WordNetClasses.WN(Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().Length - 9) + "PostQuery\\WordNet\\dict\\"); List <string> Synonyms = new List <string>(); query = query.Distinct().ToList(); //Synonyms.AddRange(WordNetExtraTerms(query)); Synonyms.AddRange(HunspellSynonymsList(query)); Synonyms.AddRange(WordNetSynonymsList(query)); if (!Properties.Settings.Default.stemmer) { int i = 0; int count = query.Count; while (i < count) { Synonyms.Add(stemmer.stemTerm(query[i])); i++; } } Synonyms = Synonyms.Distinct().ToList(); Synonyms = Synonyms.Except(query).ToList(); Synonyms = Synonyms.Take(query.Count + 1).ToList(); List <string> synonymsAfterSplit = new List <string>(); foreach (var VARIABLE in Synonyms) { synonymsAfterSplit.AddRange(VARIABLE.Split(new char[] { ' ', '-' }, StringSplitOptions.RemoveEmptyEntries)); } Synonyms = synonymsAfterSplit.Distinct().ToList(); for (int i = 0; i < Synonyms.Count; i++) { Synonyms[i] = Synonyms[i].ToLower(); } if (Properties.Settings.Default.stemmer) { for (int i = 0; i < Synonyms.Count; i++) { Synonyms[i] = stemmer.stemTerm(Synonyms[i]); } } //Synonyms = Synonyms.Except(query).ToList(); Synonyms = RemoveDuplicatesAndQueryTerms(Synonyms, query); return(Synonyms); }
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"); }