- Code: Select all
using System;
namespace CheckWordDefinedCon
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello from CheckWordDefinedCon\n");
// you must set the path to the WordNet database before performing
// any operation with the library.
string dictPath = @"C:\Program Files\WordNet\3.0\dict\";
Wnlib.WNCommon.path = dictPath;
Wnlib.PartOfSpeech noun = Wnlib.PartOfSpeech.of("noun");
string word = "dog";
bool avail = Wnlib.WNDB.is_defined(word, noun).NonEmpty;
Console.WriteLine("WordNet database is now opened for business.\n");
Console.Write(word + " as noun ");
Console.Write(avail ? "is" : "is not");
Console.WriteLine(" available.");
Console.ReadLine();
}
}
}
This console application executes only for "dog as nown". You'll need to make a new project on your favorite IDE. (Mine is VS C# Express Edition.) And copy the code above.
Why console applications? I would rather to study WordNet.NET per se so console applications are much faster than building a GUI which consumes too much time. We should build a foundation first before putting a window, should we?
The next step is to provide all parts of speech (posses) for a given word. The user inputs just a word a time and the app displays the results for all posses. A blank input ends the program.
Here are hints:
1) use definition for the posses -
string[] posses = { "noun", "verb", "adj", "adv" };
2) use do-loop to have user to input a word
3) use for-loop to check each pos for the given word
Who will be the first to post the next assignment?
I will keep watching this thread if anyone would like to participate.
Why would I give my time for this tutorial? From my long experience, teaching is the best education. Participation is the next best.
I only want to study the WordNet.NET library per se. I am not really a pro in C# programming but am still learning. I am a C/Delphi guy for years.
Have fun!
