First WordNet.NET tutorial for C# programmers

Post general questions about using the WordNet.Net library in your own project

First WordNet.NET tutorial for C# programmers

Postby KawaGeo » Wed Aug 13, 2008 8:15 pm

After I downloaded the WordNet.NET 3.0 package, I was dismayed that there were no samples for C# programming. So, I decided to convert VB samples to C# with the help of Sharp Develop Team. Here is the first sample of Check Word Defined:
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! 8)
Geo Massar
Retired Software Engineer/Teacher
KawaGeo
 
Posts: 12
Joined: Sun Aug 10, 2008 9:52 pm
Location: So. Calif. Mountains, USA

Postby KawaGeo » Fri Aug 15, 2008 5:13 pm

gerrtiio, you got an "F". 8)
Geo Massar
Retired Software Engineer/Teacher
KawaGeo
 
Posts: 12
Joined: Sun Aug 10, 2008 9:52 pm
Location: So. Calif. Mountains, USA

Postby ebswift » Fri Aug 15, 2008 10:18 pm

Thankyou KawaGeo, this is very helpful. I'm a fan of SharpDevelop myself. I have even managed to contribute a few fixes to their text editor.

BTW, gerrtiio is no longer with us 8). The spammers are sneaking back in so i may need to revisit the captcha on this forum.
~Troy
ebswift
Site Admin
 
Posts: 88
Joined: Tue Jun 07, 2005 12:41 am
Location: Queensland, Australia

Re: First WordNet.NET tutorial for C# programmers

Postby giomach » Sat May 30, 2009 8:58 pm

With all due respect to the forum title, would there be any chance of an example of how to use WordNet from Delphi, KawaGeo?
That's what I would really like to do!

Giomach.
giomach
 
Posts: 1
Joined: Sat May 30, 2009 8:47 pm


Return to Help Using WordNet.Net

Who is online

Users browsing this forum: No registered users and 1 guest

cron