private MyWordInfo[] Disambiguate(string[] words) { if (words.Length == 0) return null; MyWordInfo[] wordInfos=new MyWordInfo [words.Length]; for (int i = 0; i < words.Length; i++) { WnLexicon.WordInfo wordInfo = WnLexicon.Lexicon.FindWordInfo(words[i], true); if (wordInfo.partOfSpeech != Wnlib.PartsOfSpeech.Unknown) { if (wordInfo.text != string.Empty) words[i] = wordInfo.text; Wnlib.PartsOfSpeech[] posEnum = (Wnlib.PartsOfSpeech[])Enum.GetValues(typeof(Wnlib.PartsOfSpeech)); for (int j = 0; j < posEnum.Length; j++) { if (wordInfo.senseCounts[j] > 0) // get the first part of speech { wordInfos[i] = new MyWordInfo(words[i], posEnum[j]); break; } } } } WordSenseDisambiguator wsd = new WordSenseDisambiguator(); wordInfos=wsd.Disambiguate(wordInfos); return wordInfos; }
private MyWordInfo[] Disambiguate(string[] words) { if (words.Length == 0) { return(null); } MyWordInfo[] wordInfos = new MyWordInfo [words.Length]; for (int i = 0; i < words.Length; i++) { MyWnLexicon.WSDWordInfo wordInfo = MyWnLexicon.Lexicon.FindWordInfo(words[i], true); if (wordInfo.partOfSpeech != Wnlib.PartsOfSpeech.Unknown) { if (wordInfo.text != string.Empty) { words[i] = wordInfo.text; } Wnlib.PartsOfSpeech[] posEnum = (Wnlib.PartsOfSpeech[])Enum.GetValues(typeof(Wnlib.PartsOfSpeech)); for (int j = 0; j < posEnum.Length; j++) { if (wordInfo.senseCounts[j] > 0) // get the first part of speech { wordInfos[i] = new MyWordInfo(words[i], posEnum[j]); break; } } } } WordSenseDisambiguator wsd = new WordSenseDisambiguator(); wordInfos = wsd.Disambiguate(wordInfos); return(wordInfos); }