作为一个更大项目的一部分,我需要做一些词义消歧,我遇到了WordNet.Net 我尝试使用下载中的 WordsMatching 项目附带的 wordsensedisambiguator 类,这是我的代码
string sent = "We have investigated the inductions of the IE genes in response to calcium signals in Jurkat cells (in the presence of activated p21(ras)) and their correlated consequences.";
Tokeniser tok = new Tokeniser();
tok.UseStemming = true;
string[] words = tok.Partition(sent);
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 && 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);
当我查看结果时,每个单词的 Sense 仍然是 '0' :( 以前有人用过这个,或者任何人都可以弄清楚如何使用 WordSenseDisambiguator 吗?感谢您期待您的快速回复 :)