GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-May-2009, 00:47
SakthiGs SakthiGs is offline
New Member
 
Join Date: May 2009
Posts: 2
SakthiGs is on a distinguished road
Question

How to import English dictionary function in Visual C++


Hi..This is Sakthi.

Doubt on Using dictionary in visual c++..

i have to check whether the entered text is meaning ful or not .for that i have to include the elglish dictionary in my project..
Does we have any library in visual c++.
Could any one tell me procedure to process further

..
Thanks in advance
  #2  
Old 18-May-2009, 07:42
Kimmo Kimmo is offline
Regular Member
 
Join Date: Mar 2007
Location: Finland
Posts: 347
Kimmo is a jewel in the roughKimmo is a jewel in the roughKimmo is a jewel in the rough

Re: How to import English dictionary function in Visual C++


What do you mean by "meaningful"? Are you supposed to test single words or whole sentences?

For single words test you could try something like...

1) Download a dictionary file. Google "dictionary file download" and you should find something. I found karamasoft.com/UltimateSpell/dictionary.aspx . After downloading an English dictionary, I read the readme and it told me the file was licensed under LGPL. The license doesn't matter much if you're just going to use it for yourself, though.

Then just in your program read in the whole file into a container of words (like vector<string> or equivalent) and find out if the supposed-to-be meaningful word can be found among them. If it is found, then it's probably something meaningful. Even if it's not found, the word might still be meaningful, it just doesn't exist in your dictionary file.

The files might be pretty large and you might not want to read it all at once, in which case you could read just part of it at a time into a stream or a container of some kind, whatever you can make up.

Also, since the files can contain tens of thousands of words, the search time can be pretty long. You could reduce the needed time by creating a simple index file. That is, make a program (separate from your main application, since you only want to do this once after each update) that reads that dictionary file and writes an index file as output. The program would simply read the dictionary file and look at the first letter of each word. When encountering a new letter, it would write the letter to the output file along with the line number (or some other position indicator, like line number + column number if there were more than one word on each line) the character was encountered in.

So, it would open the file and start reading. For English, the first character of the first word would probably be 'a'. Assuming one word on each line, the program could write 'a:1' (or a1 or A::1 or whatever) to the index file. Then it would read on and at some point around line 8636 it would notice the first character of a word is no longer 'a', but is now 'b'. It could write 'b:8636' on the next line of the index file. And so on...

You might think that searching 8600 words for anything starting with an 'a' takes way too long. In that case you could update your index file to be precise up to two (or three, or more) letters. That is, instead of just telling the starting letters, it could also tell the second (and third, and...) ones. Like...

a:1
aa:2
ab:23
ac:56
etc...

Your main program could then look at this index file and see where a certain letter starts at and navigate directly to that position in the dictionary file.



If, on the other hand, by "meaningful" you mean "I need to find out if this sentence actually makes any sense", then you're probably going to need some comprehensive knowledge of the formal language rules of your target language. Whatever the case, you need to do the first part anyway, so might as well start with it.

Also note, that is just how I could do it. There might be some way more advanced and efficient ways to go about it of which I have no knowledge.
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run script command on ns2.26 newbie06 Computer Software Forum - Linux 66 16-Jan-2010 10:53
Problem executing nam-1.13 RodolfoAlvizu Computer Software Forum - Linux 20 28-Feb-2009 15:23
Build error with darkGDK header files ? genesaika MS Visual C++ / MFC Forum 4 24-Jul-2008 19:07
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
D3D error when running fullscreen games/programs - help?! daa709 Computer Hardware Forum 4 01-Jul-2005 08:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:48.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.