473,811 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Thesaurus Implementation

Hi Everybody!

Hoping that every body would be fine at this group.

I am learning c sharp. Please, if anybody can make this program, i
would be highly obliged.

Implement a thesaurus (a dictionary of synonyms) that implements the
IThesaurus interface
Interface IThesaurus
{
// Adds a word and its synonyms to the thesaurus
void AddWord(string word, string[] synonyms);
// Removes a word from the thesurus
void RemoveWord(stri ng word);
// Find the synonyms associated with a word
string[] FindSynonyms(st ring word);
// Returns a sorted list of all the words in the //thesaurus
string[] WordList();
}
Discuss your implementation. What kind of performance can you expect
from the operations? What should be done to make it threadsafe?

Thanks in Advance.

John

Sep 16 '06 #1
8 7858
Hi,

Did you try by yourself first ?
Nobody here will do a program your asked to do but we can help.
Try to use a hashtable in order to store the data.

Good work,

Martin

<jo*******@gmai l.coma écrit dans le message de news:
11************* ********@d34g20 00...legro ups.com...
Hi Everybody!

Hoping that every body would be fine at this group.

I am learning c sharp. Please, if anybody can make this program, i
would be highly obliged.

Implement a thesaurus (a dictionary of synonyms) that implements the
IThesaurus interface
Interface IThesaurus
{
// Adds a word and its synonyms to the thesaurus
void AddWord(string word, string[] synonyms);
// Removes a word from the thesurus
void RemoveWord(stri ng word);
// Find the synonyms associated with a word
string[] FindSynonyms(st ring word);
// Returns a sorted list of all the words in the //thesaurus
string[] WordList();
}
Discuss your implementation. What kind of performance can you expect
from the operations? What should be done to make it threadsafe?

Thanks in Advance.

John

Sep 17 '06 #2
This is the code i tried so far, but it is giving error.

using System;
using System.Collecti ons;

namespace Thesaurus
{

public interface IThesaurus
{
// Adds a word and its synonyms to the thesaurus
void AddWord(string word, string[] synonyms);
// Removes a word from the thesurus
void RemoveWord(stri ng word);
// Find the synonyms associated with a word
string[] FindSynonyms(st ring word);
// Returns a sorted list of all the words in the //thesaurus
string[] WordList();
}

public class ImpIThesaurus:I Thesaurus
{
#region IThesaurus Members
public Hashtable ThesDict;

public ImpIThesaurus()
{
ThesDict = new Hashtable();
}
public void AddWord(string word, string[] synonyms)
{
for ( int i = 0; i < (synonyms.Lengt h - 1); i++ )
{
ThesDict.Add(wo rd,synonyms[i]);
}
}

public void RemoveWord(stri ng word)
{
// TODO: Add ImpIThesaurs.Re moveWord implementation
}

public string[] FindSynonyms(st ring word)
{
// TODO: Add ImpIThesaurs.Fi ndSynonyms implementation
return null;
}

public string[] WordList()
{
// TODO: Add ImpIThesaurs.Wo rdList implementation
return null;
}

#endregion

}

/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
ImpIThesaurus trs = new ImpIThesaurus() ;
string[] list = {"a","b","c" };
trs.AddWord("A" ,list);

//
// TODO: Add code to start application here
//
}
}
}

Martin CLAVREUIL wrote:
Hi,

Did you try by yourself first ?
Nobody here will do a program your asked to do but we can help.
Try to use a hashtable in order to store the data.

Good work,

Martin

<jo*******@gmai l.coma écrit dans le message de news:
11************* ********@d34g20 00...legro ups.com...
Hi Everybody!

Hoping that every body would be fine at this group.

I am learning c sharp. Please, if anybody can make this program, i
would be highly obliged.

Implement a thesaurus (a dictionary of synonyms) that implements the
IThesaurus interface
Interface IThesaurus
{
// Adds a word and its synonyms to the thesaurus
void AddWord(string word, string[] synonyms);
// Removes a word from the thesurus
void RemoveWord(stri ng word);
// Find the synonyms associated with a word
string[] FindSynonyms(st ring word);
// Returns a sorted list of all the words in the //thesaurus
string[] WordList();
}
Discuss your implementation. What kind of performance can you expect
from the operations? What should be done to make it threadsafe?

Thanks in Advance.

John
Sep 19 '06 #3
johner...@gmail .com wrote:
This is the code i tried so far, but it is giving error.
Yes, because you can only have any particular key once in a hashtable.
You'll need to make the value for the entry the array of strings, or a
list, or something like that.

Jon

Sep 19 '06 #4
Hi,

Thanks for the instant reply.

I am not allowed to do that. I have to follow the interface only.
Therefore, i cannot use string array for one value. Thus, i have no
clue what to do.

Please if anyone can help me out.

John
Jon Skeet [C# MVP] wrote:
johner...@gmail .com wrote:
This is the code i tried so far, but it is giving error.

Yes, because you can only have any particular key once in a hashtable.
You'll need to make the value for the entry the array of strings, or a
list, or something like that.

Jon
Sep 19 '06 #5
johner...@gmail .com wrote:
Thanks for the instant reply.

I am not allowed to do that. I have to follow the interface only.
Therefore, i cannot use string array for one value. Thus, i have no
clue what to do.

Please if anyone can help me out.
The interface doesn't specify how you have to implement it. You could
easily follow the interface and use an array (or an ArrayList) as the
value in your hashtable, copying contents where necessary. How you
store things internally doesn't have to have an impact on how you
expose the data to the outside world.

Jon

Sep 19 '06 #6
Hi Jon,

I have implemented the method like this now:

public void AddWord(string word, string[] synonyms)
{
string[] wrd = new string[synonyms.Length];

for ( int i = 0; i < (synonyms.Lengt h - 1); i++ )
{
wrd[i] = word;
ThesDict.Add(wr d[i],synonyms[i]);
}
}

But it still give error.

An unhandled exception of type 'System.Argumen tException' occurred in
mscorlib.dll

Additional information: Item has already been added. Key in
dictionary: "A" Key being added: "A"

The program '[3064] Thesaurus.exe' has exited with code 0 (0x0).


Jon Skeet [C# MVP] wrote:
johner...@gmail .com wrote:
Thanks for the instant reply.

I am not allowed to do that. I have to follow the interface only.
Therefore, i cannot use string array for one value. Thus, i have no
clue what to do.

Please if anyone can help me out.

The interface doesn't specify how you have to implement it. You could
easily follow the interface and use an array (or an ArrayList) as the
value in your hashtable, copying contents where necessary. How you
store things internally doesn't have to have an impact on how you
expose the data to the outside world.

Jon
Sep 19 '06 #7
Hi Jon,

I have implemented the method like this now:

public void AddWord(string word, string[] synonyms)
{
string[] wrd = new string[synonyms.Length];

for ( int i = 0; i < (synonyms.Lengt h - 1); i++ )
{
wrd[i] = word;
ThesDict.Add(wr d[i],synonyms[i]);
}
}

But it still give error.

An unhandled exception of type 'System.Argumen tException' occurred in
mscorlib.dll

Additional information: Item has already been added. Key in
dictionary: "A" Key being added: "A"

The program '[3064] Thesaurus.exe' has exited with code 0 (0x0).


Jon Skeet [C# MVP] wrote:
johner...@gmail .com wrote:
Thanks for the instant reply.

I am not allowed to do that. I have to follow the interface only.
Therefore, i cannot use string array for one value. Thus, i have no
clue what to do.

Please if anyone can help me out.

The interface doesn't specify how you have to implement it. You could
easily follow the interface and use an array (or an ArrayList) as the
value in your hashtable, copying contents where necessary. How you
store things internally doesn't have to have an impact on how you
expose the data to the outside world.

Jon
Sep 19 '06 #8
jo*******@gmail .com wrote:
I have implemented the method like this now:

public void AddWord(string word, string[] synonyms)
{
string[] wrd = new string[synonyms.Length];

for ( int i = 0; i < (synonyms.Lengt h - 1); i++ )
{
wrd[i] = word;
ThesDict.Add(wr d[i],synonyms[i]);
}
}

But it still give error.
Yes, it would - you're still adding the same key multiple times, adding
just a single word each time.

Instead, make a copy of the array (eg into an ArrayList) and call Add a
single time. You'll also need to check for existing values in case
someone calls
Add ("x", firstArray);
Add ("x", secondArray);

Jon

Sep 19 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5001
by: Jaffa | last post by:
hi all, i'm currently designing a search engine. I'd like certain keywords to have affiliated synonyms listed so that I can find out which keywords are symantically related to each other. Is there a thesaurus available that I can install on the server and query via php, or possibly a server on the net that takes web-queries and returns synonyms? I am aware of word-net http://www.cogsci.princeton.edu/~wn/wn1.7.1.shtml as a possible
0
1475
by: Melody Droid | last post by:
I recently made some conceptual breakthroughs regarding the interval permutation pre-sorting and the pitch-class-set/scale post-sorting aspects of my envisioned symmetrical melody thesaurus software, so that it will take the absolute minimum of time and effort to write a computer program for it and bring it up to the demo level in order to shop the project around. I've created a Yahoo Group for the project over here: ...
3
1590
by: Jason | last post by:
Is it possible to connect and asp page to the Microsoft Office Thesaurus? I would like to be able to pass a word to it and get back all of the synonyms as either a string, array, or collection.
1
1966
by: Hans Malherbe | last post by:
I would like to access the Word thesaurus from a .NET WinForm application if the client has Microsoft Word installed. Is it possible? I could not find anything in the Office XP help.
2
1884
by: hammad | last post by:
I had made a .NET Application that use microsoft Word thesaurus using msword file when i made windows application it works well but when i try web application it make exception that i have no suffcient previllage to access the COM Component any help!!!!
3
3466
by: Marc | last post by:
Hi everyone, I'm trying to build a Thesaurus. In my thesaurus i've created the following tables: terms, btnt (broader terms/narrower terms), rt (related terms) The structures of the tables are like this: -------------------------------- | table: terms |
3
1524
by: moondaddy | last post by:
I'm looking for a thesaurus tool I can use in an application. I was hoping it could be a web service where my app could submit a work and get a list of results back which my code could use. any good ideas? -- moondaddy@noemail.noemail
0
1356
by: Piero 'Giops' Giorgi | last post by:
Hi! I have the DB, now with about 100 Million rows (Going strong!!!) One question... I'm using Thesaurus search (COOL!!!) for names, (Rebecca, Reba, Becky, Becca....) to query for nicknames ans Synonyms, but I don't seem to be able to update the XML file in real time. The file is like this:
0
1300
by: Calvin Spealman | last post by:
Sounds like you might want to read up on RDF On Tue, Aug 12, 2008 at 10:41 AM, Benjamin Michiels <benjamin.michiels@gmail.comwrote: -- Read my blog! I depend on your acceptance of my opinion! I am interesting! http://techblog.ironfroggy.com/
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.