SharpWordNet sample?

Topics: User Forum
Jan 22, 2007 at 8:03 AM
Can anyone explain how I can use SharpWordNet?
I'm using SharpNLP and am considering moving away from Wordnet.Net to SharpWordNet.
Specifically I'm looking to do the following things.

- How can I retrieve synonyms? (words withing same synset)
- How can I get a word baseform (lemma)
- How can I search holonyms / hypernyms?

Are there any samples available?
Is the use the same as

Thanks for your help.
Keep up the great work!
Feb 11, 2007 at 10:28 AM
Create a WordNetEngine by instantiating one of its concrete implementations (there is only 1 currently; the DataFileEngine, which takes a path to the WordNet database files):

SharpWordNet.WordNetEngine engine = new SharpWordNet.DataFileEngine(@"C:\Program Files\WordNet\2.1\dict");

Obtain a synset by calling GetSynset or GetSynsets with the method signature that fits your usage. For example:

SharpWordNet.Synset[] synsets = engine.GetSynsets(lemma, partOfSpeech);

Once you have a Synset object, you can a count of words (the WordCount property) and get each word by using the GetWord() method.

You can investigate the synset's relations ("currentSynset" is the Synset object):

for (int currentRelation = 0; currentRelation < currentSynset.RelationCount; currentRelation++)
SharpWordNet.Relation relation = currentSynset.GetRelation(currentRelation);
if (relation.SynsetRelationType.Name == "Hypernym")
//do something with this hypernym
//the related synset is in relation.TargetSynset

I will try to find the time to write a sample to explain these things further.
Thanks for your interest in SharpNLP.


Feb 11, 2008 at 4:10 PM

I'm not sure this is the correct place to post this question, but would appreciate any advice offered. My question concerns a specific use or method to parse a set of, let's call them "blog-type" postings, in an effort to group statistically significant clusters of concepts or similar post categories. The ultimate goal would be to produce a simple report for a C-level director that can convey topics that can be shown to have the most consistent significance from the corpus of blog postings. I have done some preliminary research on appropriate techniques that might help me in my project, but am a bit overwhelmed by the shear number of esoteric techniques that seem to lend themselves to solving problems within this domain. I seem to find that a number of techniques could be used individually such as Bayesian analysis, NLP, Monte Carlo simulation, etc., but no single one that can be utilized for anything close to an 80/20 result. As I said, I am eager to learn, but just have not been exposed to the possibilities.

Thanks kindly,
Feb 11, 2008 at 4:10 PM
Edited Feb 11, 2008 at 4:11 PM
May 26, 2011 at 5:22 PM


I have a problem with engine.GetPartsOfSpeech().

When I enter "sent" or "came" or any other past-tense it does not return any part of speech. I was wondering why.

I tried WordNet browser and it seems that it is in the WordNet, but the method can not return it.

Any solutions?