Obi*_*Obi 2 nlp wordnet word-sense-disambiguation
我需要做一些词义消歧作为一个更大的项目的一部分,我遇到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);
Run Code Online (Sandbox Code Playgroud)
当我查看结果时,每个单词的Sense仍然是'0':(哈斯之前有人使用过这个或任何人都可以找出如何使用WordSenseDisambiguator?感谢您对加速的反应的期待:)
小智 6
你可能想试用WordNet :: SenseRelate :: AllWords,它可以让所有单词使用WordNet来感知diambiguation.
http://senserelate.sourceforge.net
通过网络界面试试吧